here is the html content
<div id="result-box" class="col-5">
<h3 class="result" id="name" >Name: --- </h3>
<h3 class="result" id="age">Age: ---</h3>
<h3 class="result" id="class">Class: --- </h3>
<h3 class="result" id="skill">Skill:--- </h3>
<h3 class="result" id="gen">Gender: --- </h3>
<h3 class="result" id="perform">Perfomance: --- </h3>
</div>
here is the js code You tell me what is the error/mistake in this
let name = document.getElementById('name').value;
let age = document.getElementById('age').value;
let class = document.getElementById('class').value;
let skil = document.getElementById('skill').value;
let gen = document.getElementById('gen').value;
let perform = document.getElementById('perform').value;
let name = document.getElementById('name').value
console.log(name)
In console panel it says undefined what is reason behind this, please guide me
2
Answers
You have a few mistakes that could cause your behavior:
You shouldn’t define ‘name’ twice. If you want to overwrite the variable, then you mustn’t repeat the ‘let’.
You can’t use ‘class’ as a variable, it’s reserved