Back to Freecodecamp

Step 12

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

latest1.5 KB
Original Source

--description--

Now it is time to access the last character of a string.

Start by adding another console statement that outputs the message Here is an example of accessing the last letter in the word [subject].

Remember to replace [subject] with the actual value of the subject variable and use correct template literal syntax.

--hints--

Your console statement should output the message Here is an example of accessing the last letter in the word [subject]. Remember to use the correct template literal syntax.

js
assert.match(code, /console\.log\(`Here\s+is\s+an\s+example\s+of\s+accessing\s+the\s+last\s+letter\s+in\s+the\s+word\s+\${subject}\.`\);?/);

--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);

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

console.log(`Here is an example of accessing the first letter in the word ${subject}.`);

console.log(subject[0]);

console.log(`Here is an example of accessing the second letter in the word ${subject}.`);
console.log(subject[1]);

--fcc-editable-region--

--fcc-editable-region--