Build a JavaScript Trivia Bot - Build a JavaScript Trivia Bot

Tell us what’s happening:

The test #9 fails with message “You should log to the console “My favorite programming language is (favoriteLanguage).” using concatenation to add the variable to the string.” All the rest tests pass OK.

When I change first assignment to favoriteLanguage from “JavaScript” to “javaScript”, or “python”, or any other string starting with a lowercase letter, tests #9 and #12 don’t pass (12. You should log codingFact to the console.). But the output to the console is exactly as it should be.

Your code so far

console.log("Hello! I'm your coding fun fact guide!");
let botName = "Superbot";
let botLocation = "all PCs";
let favoriteLanguage = "JavaScript";
console.log("My name is " + botName + " and I live on " + botLocation + ".");
console.log("My favorite programming language is " + favoriteLanguage + ".");
let codingFact = "My favorite coding fact about " + favoriteLanguage + " programming is favourite fact.";
console.log(codingFact);
favoriteLanguage = "Java";
codingFact = "My favorite coding fact about " + favoriteLanguage + " programming is different fact.";
console.log(codingFact);
codingFact = "My favourite coding fact about " + favoriteLanguage + " programming is another fact.";
console.log(codingFact);
console.log("It was fun sharing these facts with you. Goodbye! - " + botName + " from " + botLocation + ".");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Build a JavaScript Trivia Bot - Build a JavaScript Trivia Bot

Welcome to the forum @Navka

When I delete lines seven and below from your code, text 9 passes.

Check you don’t have any extra code.
If that doesn’t work, make sure the code is in the order given in the instructions.

Happy coding

There is no extra code or extra spaces. The code is in the order given in the instructions. The resulting output is this:

Hello! I’m your coding fun fact guide!
My name is Superbot and I live on all PCs.
My favorite programming language is JavaScript.
My favorite coding fact about JavaScript programming is favourite fact.
My favorite coding fact about Java programming is different fact.
My favourite coding fact about Java programming is another fact.
It was fun sharing these facts with you. Goodbye! - Superbot from all PCs.

It is copypasted from the console. Can’t even imagine how is it possible to pass this test at all without knowing exactly what the test cases expect under the hood.

That hint is mis-leading. This is also a clue:

It’s something you do after this line that messes up the test. Sometimes it helps to go back to the instructions.

Look at instructions 9-13 again. Only do what the instructions ask, if you change a variable that the tests aren’t expecting it will fail.

console.log('My favorite programming language is ' + favoriteLanguage+".");

let codingFact = "My coding fact about " + favoriteLanguage + " programming is favourite fact.";
console.log(codingFact);
favoriteLanguage = "Java";
codingFact = "My favorite coding about " + favoriteLanguage + " programming is different fact.";

Ok, I went through all instructions again today one more time with a fresh mind, and found where I was wrong. I changed the value of favoriteLanguage though there were no instruction to do this (though I was sure there was). I deleted this string, and voila, everything works. Just couldn’t see the obvious lol. :roll_eyes:

Thx for help!

1 Like

Yes, that was really mis-leading. Try to keep in mind that the tests are just automated scripts and do the best they can. Even if they aren’t exactly accurate they can be a clue to lead you to the problem.

In this case you changed the favoriteLanguage variable after the console log so when the test checked your sentence the favoriteLanguage wasn’t what it expected.

i had the same problem i just went back and tried a different way and it PASSED!! here below is the way it should look: solution removed by moderator

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.