+ 6
Pls the console keeps telling me that appendChild is not a function and I am getting confused
9 odpowiedzi
+ 1
If you want to reuse the code create the following function.
function makeEl(el){
return document.createElement(el)
}
//then call like so
table=makeEl(‘table’)
I’ve never seen tr*=2 being used before.
+ 5
What is the purpose of
tr*=2
td*=3
//line 37
+ 3
The reason you are receiving the error message is that you inadvertently converted(implicit coercion) tr and td, at lines 37 and 38, from HTML element objects to numbers, in this case, NaN.
So td.appendChild(value) equates to NaN.appendChild(value) thus causing the error message "Uncaught TypeError: td.appendChild is not a function..."
Using console.log to visualize the promblem
https://code.sololearn.com/WyQUP48ToYYP/#html
"What you need to know about javascript implicit coercion"
https://dev.to/promhize/what-you-need-to-know-about-javascripts-implicit-coercion-e23
Another Alternative Solution
https://code.sololearn.com/WTEZ208cE67U/#html
+ 2
Jaydeep Khatri
I wanted to save stress of creating more of the same elements
And also that is not the error the console is raising
+ 2
ButNasif Rahman but how am I going to get the id then because the code itself is Already complex
And I don't want to use document.getElementsByTagName
+ 2
Nasif Rahman thanks a lot I'm grateful
+ 2
Thanks a lot Mirielle
+ 1
Thanks