Build a Greeting Bot - Step 14

Tell us what’s happening:

Next, create a variable called favoriteSubjectSentence.

Use string concatenation to join the string "My favorite subject is " with the favoriteSubject variable followed by a period.

Assign the result to the favoriteSubjectSentence variable.

Then, log the value of favoriteSubjectSentence to the console.

My code is this:
let favoriteSubject = “Computer Science”;

let favoriteSubjectSentence = "My favorite subject is " + favoriteSubject + “.”;

console.log(favoriteSubjectSentence);
problem

Your code so far

console.log("Hi there!");
console.log("I am excited to talk to you.");

let bot;
let botLocation;

bot = "teacherBot";
botLocation = "the universe";

console.log("Allow me to introduce myself.");

const botIntroduction = "My name is " + bot + ".";
console.log(botIntroduction);

const botLocationSentence = "I live in " + botLocation + ".";
console.log(botLocationSentence);

bot = "professorBot";

const nicknameIntroduction = "My nickname is " + bot + ".";
console.log(nicknameIntroduction);

bot = "awesomeTeacherBot";

const newNicknameGreeting = "I love my nickname but I wish people would call me " + bot + ".";
console.log(newNicknameGreeting);

const favoriteSubject = "Computer Science";


// User Editable Region

let favoriteSubject = "Computer Science";  

let favoriteSubjectSentence = "My favorite subject is " + favoriteSubject + ".";  

console.log(favoriteSubjectSentence);


// 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/139.0.0.0 Safari/537.36

Challenge Information:

Build a Greeting Bot - Step 14
https://www.freecodecamp.org/learn/full-stack-developer/workshop-greeting-bot/step-14

you can’t declare the same variable twice, aren’t you seeing an error in the console?

1 Like