+ 2
20th Dec 2020, 8:06 PM
Ibrahim Yusuf
Ibrahim Yusuf - avatar
3 Answers
+ 2
The reason your code returns NaN, is due to the if statement. if (ab[i].innerText == ""){...} It reads... ...if the inner text of ab[i] is equal to an empty string, add that value to the variable count. There is only one element of the table that is equal to an empty string, the first element. And using parseInt on an empty string returns NaN. Try this: if (ab[i].innerText)
21st Dec 2020, 4:19 PM
ODLNT
ODLNT - avatar
+ 1
replace the for in with for of
20th Dec 2020, 11:44 PM
Logomonic Learning
Logomonic Learning - avatar
+ 1
ODLNT Thank you
21st Dec 2020, 6:10 PM
Ibrahim Yusuf
Ibrahim Yusuf - avatar