JavaScript JavaScript Basics Working with Strings Combine Strings and Template Literals Review

i need help with this quiz

I don't get what to put in the fill the blanks question

What is the question?

Steven Parker
Steven Parker
207,973 Points

There's more than one "blanks" question in this quiz.

3 Answers

Indiya Gooch
Indiya Gooch
12,008 Points

Consider the following code:

let greeting = 'Hi';
greeting = greeting + ', Treehouse students!';

Complete this code by adding the operator that produces the same result as the above code:

let greeting = 'Hi';
greeting **+=** ', Treehouse students!';

Reason:The addition assignment operator adds the value of the right operand (the stuff on the right side of the =) to a variable and assigns the result to the variable. 

Link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment

Complete the code below to create a template literal:

const headline =  **` **<h1>A Literal Headline</h1> **` **;

Consider the following code:

const name = "Aneesah";
let message = "Hello " + name + ". How are you?";

Complete the code below to recreate the above code using template literal interpolation:

const name = "Aneesah";
let message = ** `Hello ${name}. How are you?` **;

Reason: Template literals are enclosed by the backtick ()  (grave accent) character instead of double or single quotes. Template literals can contain placeholders - indicated by the dollar sign and curly braces (${expression}). The expressions in the placeholders and the text between the backticks () get passed to a function.

The default function just concatenates the parts into a single string. 

Link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

+= and += didn't work. What's the correct stuff to put in the blank space? Here's the Quiz Question again:

Consider the following code:

let greeting = 'Hi'; greeting = greeting + ', Treehouse students!'; Complete this code by adding the operator that produces the same result as the above code:

let greeting = 'Hi'; greeting ', Treehouse students!'; <----fill in blank space after greeting

https://teamtreehouse.com/library/javascript-basics/working-with-strings/combine-strings-and-template-literals-review