In example – 1 I am getting all the values Entered from the Prompt box.
//Example – 1
<button id="btn">Click Here</button>
<div id="data1"></div>
<div id="data2"></div>
document.getElementById("btn").onclick = () => {
let cars = new Array(5);
for(let get = 0 ; get <= 5 ; get++){
cars[get] = prompt("Enter Any Values");
}
for(let show = 0 ; show <= 5 ; show++ ){
document.getElementById("data1").innerHTML += `You have Entered : ${cars[show]}<br>`;
}
document.getElementById("data2").innerHTML = `The Total Values are : ${cars}`;
}
I am Facing a Problem in Example – 2 .please tell me Where I did wrong. Thank You..!
//Example – 2
<button id="btn">Click Here</button>
<div id="data1"></div>
<div id="data2"></div>
document.getElementById("btn").onclick = () => {
let cars = new Array(5);
for(let get of cars){
cars[get] = prompt("Enter Any Values");
}
for(let show of cars){
document.getElementById("data1").innerHTML += `You have Entered : ${cars[show]}<br>`;
}
document.getElementById("data2").innerHTML = `The Total Values are : ${cars}`;
}