Here is the link to my codepen code:
I did it by following the instructions in the page, and did not get the o/p, I verified my code with the solution, but not getting where the error is.
Kindly look into the code and help me resolving this.
Here is the link to my codepen code:
I did it by following the instructions in the page, and did not get the o/p, I verified my code with the solution, but not getting where the error is.
Kindly look into the code and help me resolving this.
When you open the console in your browser and click the button, you will get this error: “Uncaught ReferenceError: input is not defined”. This tells us that we used the variable “input” which wasn’t defined before. This often happens when we have a typo somewhere. Looking at your code I see that the variable was defined as const basicInput
. After you’ve corrected this error (either by changing the definition or where you used the variable) you will see that another variable has the same problem and needs to be fixed the same way.
As a general advice: When coding JS you should always have a look at the browser console when something isn’t right.
Please tell me if you need more help.
Have a nice day,
Michael
Good evening @mikoMK, I did not know about this feature earlier,I am so thankful to you.
Yes , u were right, there were 3 variables which I needed to change, at input.value and input.focus().
Thank you for your patience and for a detailed explanation.
Sure, I will definitely follow to have a look at the js console to know the status of my program.
Thank you again
Good work! Which page on MDN Web Docs did you work from?
Regarding the use of the button
element. It is generally best practice to always specify the type
attribute on a button
. In this instance the default of submit
is what you want but, for future reference, I would be explicit as follows:
<button type="submit">Add item</button>
Let us know when you have had some time to update the code in the Codepen.