Reading through the forum, the answer on this code might seem off, but could someone walk me through why this is not the beginning process of the answer
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function addEntry() {
targetId += "#";
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 40
that’s the compound assignment, and it appends to the previous value of the variable, You are creating targetId there, so it doesn’t have a previous value. = is assignment, + is the concatenation operator.
Do you mean how to use the + operator? You use it between two strings to obtain a string that is the two previous strings joined together "a" + "b" makes "ab"
You need to use the +, yes. You are already using concatenation.
But you can’t use the compound assignment as that is equal to let targetId = targetId + ... and targetId doesn’t exist yet, you are initializing it here