Why this js code not working:((?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this js code not working:((??

https://code.sololearn.com/WFZSI625fwKw/#html which part of this js code is wrong and how to fix?

6th Oct 2020, 1:49 PM
MAHDI
MAHDI - avatar
3 Answers
+ 6
if (x[0].textContent.includes("posts")) { not x "Elements"ByClassName not "Element"ByClassName ,(notice the s after Element) So basically Elements one returns a node list with all elements having similar class name and you need to specify by indexing which one you wanna select out of it
6th Oct 2020, 1:54 PM
Abhay
Abhay - avatar
6th Oct 2020, 1:56 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
+ 2
Although insignificant, also notice that you have unnecessary { bracket at line 33, and its counter } bracket at line 39.
6th Oct 2020, 2:06 PM
Ipang