Tell us what’s happening:
Hello everyone,
I’m having trouble figuring out what I need to do here. My code produces the desired output in the tests but I don’t exactly understand the way it wants me to do this. Any help is appreciated. I don’t think I was supposed to declare a new variable the way I did.
Step 8: Now it is time to get the length of the topic
string.
You can use template literals inside console
statements like this:
Example Code
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.
Your code so far
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);
// User Editable Region
const strLengthTopic = `Here is an example of using the length property on the word ${topic}.`;
console.log(strLengthTopic);
console.log(topic.length);
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build a Teacher Chatbot - Step 8