+ 6

Pls the console keeps telling me that appendChild is not a function and I am getting confused

https://code.sololearn.com/W5TJLD6DmHOQ/?ref=app

14th Nov 2020, 1:02 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
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.
15th Nov 2020, 11:54 AM
Logomonic Learning
Logomonic Learning - avatar
+ 5
What is the purpose of tr*=2 td*=3 //line 37
14th Nov 2020, 1:26 PM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 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
14th Nov 2020, 9:40 PM
ODLNT
ODLNT - avatar
+ 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
14th Nov 2020, 1:29 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 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
14th Nov 2020, 1:50 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 2
Nasif Rahman thanks a lot I'm grateful
14th Nov 2020, 2:06 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 2
Thanks a lot Mirielle
14th Nov 2020, 5:25 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 1
Thanks
15th Nov 2020, 1:15 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar