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)

8th May 2021, 1:06 PM
Тимур Завьялов
Тимур Завьялов - avatar
2 odpowiedzi
+ 1
Your condition is never reached because b.length is less than numberTwo
8th May 2021, 1:13 PM
Alpha Diallo
Alpha Diallo - avatar
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; } }
8th May 2021, 1:17 PM
Тимур Завьялов
Тимур Завьялов - avatar