Back to Freecodecamp

Step 7

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

latest1.1 KB
Original Source

--description--

To get the length of a string, you can use the <dfn>length</dfn> property. This property returns the number of characters in a string.

Here is an example:

js
const greeting = "Hello, world!";

// Output: 13
console.log(greeting.length);

Start by using the length property to get the length of the subject string and log that value to the console.

--hints--

You should use the length property to get the length of the subject string.

js
assert.match(code, /subject\.length/);

You should log the length of the subject string to the console.

js
assert.match(code, /console\.log\(\s*subject\.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);

--fcc-editable-region--

--fcc-editable-region--