I don’t understand what I am missing. I typed the answer how the example question did, but it still has an error. Can anyone else see what I am doing wrong?
And if it isn’t too much trouble, any explanation as to what I am doing wrong and why would be super helpful!
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);
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}.`);
// User Editable Region
let lastCharacter = subject;
lastCharacter[lastCharacter.length - 1];
console.log(lastCharacter);
// 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/132.0.0.0 Safari/537.36
I noticed the “Jessica” string in the example but the assignment says to assign “subject” as the variable. They didn’t give me a string. Am I supposed to make one up?
You are asked to create a lastCharacter variable and assign it the last character of the string that was assigned to the subject variable, then log it out.
The code I listed above in the original post is “officially” the code I am using. Anything else I try is just on a whim and I end up reverting back to this one in case anyone has any insight into what I am doing wrong.
@Teller THANK YOU! I was not understanding the instructions but what you said helped me understand 1) what I did wrong in my code and 2) what I actually needed to focus on. That is exactly what I needed.