Back to Freecodecamp

Step 14

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

latest1.7 KB
Original Source

--description--

For the last part of the workshop, you will review how to find the index position of substring in a string. Remember that a substring is a part of a string.

Start by creating a variable called learningIsFunSentence and assign it the string value of "Learning is fun.".

--hints--

You should have a variable called learningIsFunSentence.

js
assert.isNotNull(learningIsFunSentence);

Your learningIsFunSentence should hold the value of a string.

js
assert.isString(learningIsFunSentence);

You should assign the value of "Learning is fun." to the variable learningIsFunSentence.

js
assert.equal(learningIsFunSentence, "Learning is fun.");

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

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

const lastCharacter = subject[subject.length - 1];
console.log(lastCharacter);

--fcc-editable-region--

--fcc-editable-region--