xxxxxxxxxx
countString() {
// contact me !!!
// linkedIn account : https://www.linkedin.com/in/mohammad-alshraideh-67820b186/
if (!this.head) return "the LL is Empty";
let res = [];
let count = 0;
let current = this.head;
while (current.next) {
if (typeof current.value === "string") {
res.push(current.value);
count++;
}
current = current.next;
}
if (count > 1) {
console.log(
`there are : ${count} String in the LL and they are : (${res})`
);
}
if (count <= 1) {
console.log(
`there is only one String in the LL and he/she is : (${res})`
);
}
return count;
}
//if you find the answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)