Can you show me how to retrieve the name
, age
, and salary
from the products
array?
Also, could you please explain what is wrong with the code?
var products = [
{name: 'John', age: 30, salary: 400},
{name: 'Jane', age: 31, salary: 500},
{name: 'Jim', age: 32, salary: 600},
];
var btn = document.getElementById("myBtn");
btn.addEventListener("click", funct);
function funct(){
for( var i = 0; i < products.length; i++ ){
document.write( " this " + products[i] );
}
return;
}
console.log(funct());
<button id="myBtn">Start</button>