Forum Discussion
Need help checking my JavaScript
- 7 hours ago
Look at section 2, you never defined retail, collxns, traffic, or cust, you defined retail1, retail2, retail3, etc. Also your template only outputs 4 boxes, not 12. Even after the ReferenceError is fixed, the HTML only references one variable per scenario, so you’d lose 8 of the 12 answers.
Look at section 2, you never defined retail, collxns, traffic, or cust, you defined retail1, retail2, retail3, etc. Also your template only outputs 4 boxes, not 12. Even after the ReferenceError is fixed, the HTML only references one variable per scenario, so you’d lose 8 of the 12 answers.
- JamesGregg7 hours agoCommunity Member
Thank you! As you have likely deduced, I am a bit of a JS newbie (well, I did it about 25 years ago when I was hardcoding webpages from scratch, but....the brain fade is real ;)) I appreciate your helpful and prompt reply!
- DShaw7 hours agoCommunity Member
Also worth noting with your code; a stray < or & in someone’s notes might mangle the output. If it were me I’d escape the input. Something like this:
function esc(s){ return String(s) .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") .replace(/\r\n|\r|\n/g, "<br>"); }