Is there something wrong with my code | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Is there something wrong with my code

if (a === 50) { var upgradeOne = document.createElement("button"); upgradeOne.onclick = "newUpgrade()"; upgradeOne.innerHTML = "Would You Like To Upgrade?"; document.body.appendChild(upgradeOne.); }

29th May 2024, 6:10 PM
5 Antworten
+ 2
, your code seems to be incomplete. this makes it difficult to help. read the error messages you get when code is executing. try to solve the issues step by step.
29th May 2024, 6:54 PM
Lothar
Lothar - avatar
0
What if the person wants to upgrade, but a is 72?
29th May 2024, 7:06 PM
Annihilate
Annihilate - avatar
0
I think it is a syntax error: document.body.appendChild(upgradeOne.); It should be: document.body.appendChild(upgradeOne); also Instead of upgradeOne.onclick = "newUpgrade()"; should be upgradeOne.onclick = newUpgrade; here is the full code: if (a === 50) { var upgradeOne = document.createElement("button"); upgradeOne.onclick = newUpgrade; upgradeOne.innerHTML = "Would You Like To Upgrade?"; document.body.appendChild(upgradeOne); } I hope it work: J
29th May 2024, 7:18 PM
Nawaf Alorabi
Nawaf Alorabi - avatar
0
It still doesnÔÇÖt fix the point I described earlier.
29th May 2024, 8:59 PM
Annihilate
Annihilate - avatar
0
I fixed it for the most part thank you
30th May 2024, 2:49 PM