JS Test
JS Test
function example() {
console.log(a);
var a = 10;
console.log(a);
}
example();
let x = 5;
function foo() {
x = 10;
}
foo();
console.log(x);
a) function printNumbers() {
for (var i = 0; i < 5; i++) {
setTimeout(function() {
console.log(i);
}, 100);
}
}
printNumbers();
b) function printNumbers() {
for (let i = 0; i < 5; i++) {
setTimeout(function() {
console.log(i);
}, 100);
}
}
printNumbers();
console.log('Name:', name);
console.log('Age:', age);
a1) How can I access the name and age of the second person in the array?
a2) What is the occupation of the last person in the array?
a3) Show me how to access and print all the names of the people in the array
c1) How can I filter out people who are younger than 30?
c2) Show me all the people who have "Engineer" as their occupation.
c3) How do I get an array of people's names who are older than 30?