0
0
Javascriptprogramming~10 mins

Object creation in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an empty object named person.

Javascript
const person = [1];
Drag options to blanks, or click blank then click option'
A{}
B[]
Cnull
D''
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using square brackets creates an array, not an object.
Using quotes creates a string, not an object.
2fill in blank
medium

Complete the code to create an object car with a property make set to 'Toyota'.

Javascript
const car = [1];
Drag options to blanks, or click blank then click option'
Amake: 'Toyota'
B['make', 'Toyota']
C('make', 'Toyota')
D{make: 'Toyota'}
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using square brackets creates an array, not an object.
Leaving out curly braces causes syntax errors.
3fill in blank
hard

Fix the error in the code to create an object book with a property title set to 'JavaScript'.

Javascript
const book = [1];
Drag options to blanks, or click blank then click option'
A{title: 'JavaScript'}
B{title = 'JavaScript'}
C[title: 'JavaScript']
D(title: 'JavaScript')
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using equals sign = instead of colon : in object literals.
Using square brackets or parentheses instead of curly braces.
4fill in blank
hard

Fill both blanks to create an object user with properties name and age.

Javascript
const user = [1] name[2] 'Alice', age: 30 };
Drag options to blanks, or click blank then click option'
A{
B[
C:
D=
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using square brackets instead of curly braces to start the object.
Using equals sign = instead of colon : for properties.
5fill in blank
hard

Fill all three blanks to create an object product with properties id, name, and price.

Javascript
const product = [1] id[2] 101, name[3] 'Pen', price: 1.5 };
Drag options to blanks, or click blank then click option'
A{
B:
C,
D=
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using equals sign = instead of colon :.
Forgetting commas between properties.