0
0
Javascriptprogramming~10 mins

String concatenation in output 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 print the greeting message.

Javascript
console.log('Hello, ' + [1] + '!');
Drag options to blanks, or click blank then click option'
A123
B'name'
Cname
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name, which prints the word instead of its value.
2fill in blank
medium

Complete the code to join first and last names with a space.

Javascript
let fullName = firstName + [1] + lastName;
Drag options to blanks, or click blank then click option'
A' '
B""
C'-'
D'_'
Attempts:
3 left
💡 Hint
Common Mistakes
Using no space or wrong separator characters like underscore or dash.
3fill in blank
hard

Fix the error in concatenating number and string.

Javascript
let message = 'You have ' + [1] + ' new messages.';
Drag options to blanks, or click blank then click option'
AmessageCount
B'5'
C5
Dfive
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string literal '5' instead of the variable holding the count.
4fill in blank
hard

Fill both blanks to create a sentence with age and city.

Javascript
let info = 'I am ' + [1] + ' years old and live in ' + [2] + '.';
Drag options to blanks, or click blank then click option'
Aage
B'age'
Ccity
D'city'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around variable names, which prints the names instead of values.
5fill in blank
hard

Fill all three blanks to build a full greeting sentence.

Javascript
let greeting = 'Hello, ' + [1] + '! You are ' + [2] + ' years old and from ' + [3] + '.';
Drag options to blanks, or click blank then click option'
AuserName
BuserAge
CuserCity
D'userName'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around variable names, causing incorrect output.