Objects Flashcards
1
Q
Make the function display “Hello” in the inner HTML of an element with the ID “demo”.
A
document.getElementById(“demo”).innerHTML = “Hello”;
2
Q
Add the following properties and values to the person object: firstName: John, lastName: Doe, country: Norway.
var person = {
};
A
firstName: “John”,
lastName: “Doe”,
country: “Norway”
3
Q
Create an object called person with name = John, age = 50.
A
let person = { name: "John", age: 50 };
4
Q
access the object to alert(“John is 50”).
var person = { name: "John", age: 50 };
A
alert(person.name + “ is “ + person.age);