TGViewer
Programming Quiz Channel Programming Quiz Channel @programming_quizz · 796 subscribers
Post #290 831
Find the error in the code.
Difficulty: Hard😤

function processArray(arr) {
let result = [];

arr.forEach(item => {
if (item != '') {
result.push(item);
} else if (typeof item === 'number') {
result.push(item * 2);
}
});

return result;
}

let data = [1, '', 2, 3, '', 5, null, undefined, 'hello'];

console.log(processArray(data));
  • ❤ 3
  • 👍 1
  • 🔥 1
More from @programming_quizz
  1. Oct 14, 2026Post #572
  2. Oct 12, 2026Post #571
  3. Oct 10, 2026Post #570
  4. Oct 8, 2026Post #569
  5. Oct 6, 2026Post #568
  6. Oct 4, 2026Post #567
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →