curriculum/challenges/english/blocks/workshop-teacher-chatbot/66b6fdb76441c738719039fa.md
In previous lessons, you learned how to access the last character in a string like this:
const firstName = "Jessica";
// returns "a"
firstName[firstName.length - 1];
string.length - 1 will always give you the last index number for a string.
Create a new variable called lastCharacter and assign it the value of the last character in the subject variable.
Then, log the value of the lastCharacter variable to the console.
You should have a variable called lastCharacter.
assert.isNotNull(lastCharacter);
You should assign the value of the last character in the subject variable to the lastCharacter variable. Refer to the example if you need help.
assert.strictEqual(lastCharacter, subject[subject.length - 1]);
You should log the value of the lastCharacter variable to the console.
assert.match(code, /console\.log\(lastCharacter\)/);
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]);
console.log(`Here is an example of accessing the last letter in the word ${subject}.`);
--fcc-editable-region--
--fcc-editable-region--