+ 5

Why the name in this code get "undefined" value?

The "cost" value is fine, but wy the "name" value get undefined? https://code.sololearn.com/WPzaEty7T6QG/?ref=app

3rd Feb 2019, 12:33 AM
Jingga Sona
Jingga Sona - avatar
3 Respostas
+ 8
It’s because I’m pretty sure name is already a variable. So if you change ths id of the input to Name, and change name to Name in the JS, it should work. BTW in the name input, it says type"text" instead of type="text".
3rd Feb 2019, 1:41 AM
Rowsej
Rowsej - avatar
+ 5
Thanks a lot Rowsej! I dont know name is a variable😅 And thanks for the input!👍
3rd Feb 2019, 3:46 AM
Jingga Sona
Jingga Sona - avatar
+ 2
name is an empty string. Try console.log(typeof(name)) console.log(name==='') to check
3rd Feb 2019, 7:53 AM
Calviղ
Calviղ - avatar