Design comparison
SolutionDesign
Solution retrospective
please your feedback is needed here....pls so that i can correct my mistake
Community feedback
- @khaya05Posted over 1 year ago
Hey Timothy
Here are a few things that you can do to improve your code.
Firstly, use variables when selecting your DOM elements, preferably at the top of your file.
Instead of this:
function goStepThree() { console.log(typeof document.getElementById("totalPrice").innerHTML); if (document.getElementById("totalPrice").innerHTML == "") { console.log(document.getElementById("totalPrice").innerHTML); document.getElementById("totalPrice").innerHTML = "0"; console.log(document.getElementById("totalPrice").innerHTML); } checkPlan(); }
Use variables:
const totalPrice = document.getElementById("totalPrice") function goStepThree() { if (totalPrice.innerHTML == "") { console.log(totalPrice.innerHTML); totalPrice.innerHTML = "0"; } checkPlan(); }
Also, use
const
orlet
when declaring variables0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord