SCT doesn't accept interpolation

I’m confused. In the previous sections of this topic, we were using

return This is my text ${} (with the tilde/backtick)

and so I thought for advanced objects, we were supposed to use ` instead of ’ (like what we were told at the basics of javascript for indicating text). I spent some frustrating minutes wondering why

return My current energy level is ${this._energyLevel} (with the tilde/backtick)

was not being accepted, only to get furious upon knowing that the solution is back to

return ‘My current energy level is ’ + this._energyLevel’ (with the apostrophe)

I’m beginning to find this language a little too much by not being consistent. Why is it suddenly back to using ’ instead of ` ? When are we supposed to use them?

It’s just two methods of completing the same task. Sometimes the SCT (submitted code tester) for the lessons will only accept one of the ways instead of both. It’s probably due to not all lessons being updated since string interpolation was introduced to JavaScript. Both of these methods are correct:

return `This sentence contains a variable ${someVariable}.`;
return 'This sentence contains a variable ' + someVariable + '.';

But the SCT for any given lesson may only accept one. I know it’s a bit frustrating, but it isn’t an issue with the language. Happy coding!

Great! It’s nice knowing that I was doing the right thing. I hope these lessons can be updated to prevent misleading people when their code is actually correct. Thanks! :slight_smile:

1 Like

Hey thanks for posting about this. I just double checked and it looks like we got it fixed sometime afterwards.

1 Like

it just did it to me