Back to Freecodecamp

Step 8

curriculum/challenges/english/blocks/workshop-teacher-chatbot/66b6e62423e8a031d6c1f03d.md

latest1.6 KB
Original Source

--description--

Now it is time to get the length of the topic string.

You can use template literals inside console statements like this:

js
const developer = "Jessica";
console.log(`Hello, my name is ${developer}.`);

Start by outputting the message Here is an example of using the length property on the word [topic]. to the console.

Remember to replace [topic] with the topic variable, and use proper template literal syntax as you did in the previous steps.

Then, add a second console.log statement that outputs the length of the topic string to the console.

--hints--

You should use template literal syntax to output the message Here is an example of using the length property on the word [topic]. to the console.

js
assert.match(code, /console\.log\(`Here\s+is\s+an\s+example\s+of\s+using\s+the\s+length\s+property\s+on\s+the\s+word\s+\$\{topic\}\.`\)/);

You should have a second console statement to output the length of the topic variable to the console.

js
assert.match(code, /console\.log\(\s*topic\.length\s*\)/);

--seed--

--seed-contents--

js
console.log("Hi there!");

const botName = "teacherBot";

const greeting = `My name is ${botName}.`;
console.log(greeting);

const subject = "JavaScript";
const topic = "strings";

const sentence = `Today, you will learn about ${topic} in ${subject}.`;
console.log(sentence);

const strLengthIntro = `Here is an example of using the length property on the word ${subject}.`;
console.log(strLengthIntro);
console.log(subject.length);

--fcc-editable-region--

--fcc-editable-region--