Why this code doesn't work? | Sololearn: Learn to code for FREE!

0

Why this code doesn't work?

let b = ['eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen '] function digital( numberTwo) { for (let j = 1; j < b.length; j++) { if (j == numberTwo) { j -= 10; console.log(b[j - 1]); } } } digital(12)

5/8/2021 1:06:57 PM

Тимур Завьялов

2 Answers

New Answer

+1

Your condition is never reached because b.length is less than numberTwo

0

Alpha, thank you, I already correct for (let j = 1; j <= b.length + 10; j++) { if (j == numberTwo) { j -= 10; console.log(b[j - 1]); break; } }