Back to Freecodecamp

Step 10

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

latest1.4 KB
Original Source

--description--

In previous lessons, you learned how to access characters in a string like this:

js
const firstName = "Jessica";
// returns "J"
firstName[0];

Remember that index numbers start at 0, so the first letter in a string will always be at index 0.

Start by adding another console statement.

Inside the console statement, output the first letter of the subject variable using bracket notation and the correct index number.

--hints--

Your console statement should output the first letter of the subject variable using bracket notation and index 0.

js
assert.match(code, /console\.log\(subject\[0\]\);?/);

--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}.`);

--fcc-editable-region--

--fcc-editable-region--