Interactivity with onclick

Hey folks,

what am I missing? Why would the following not be accepted:

let element = document.querySelector("button");

function turnButtonRed (){
  element.style.backgroundColor = 'red';
  element.style.color = 'white';
  element.innerHTML = 'Red Button';
}

But this one from the solution be accepted:

let element = document.querySelector("button");

function turnButtonRed (){
  element.style.backgroundColor = "red";
  element.style.color = "white";
  element.innerHTML = "Red Button";
}

Please include the exercise url

[https://www.codecademy.com/paths/web-development/tracks/building-interactive-javascript-websites/modules/web-dev-interactive-websites/lessons/javascript-dom/exercises/onclick-element]

the strings have to be enclosed quotation marks, enclosing the strings in apostrophes won’t get approved

Thanks for you help! But is this a bug in the lesson? It’s just odd, since the apostrophes did just fine in all environments so far. Even the example, hint, and instructions of the lesson have apostrophes. So either the interpreter or the examples appear to be wrong.

in some exercises, the validation seems to be configured in such a way that only one of the two possible options of enclosing is approved, while both are perfectly fine supported by javascript.

I thought so since I couldn’t find any reference on it. I haven’t encountered such an issue yet though. So it doesn’t seem to be common. It should nevertheless be fixed, as I spent a valuable half an hour on trying to understand what could possibly be wrong with my code.

In any case, thanks a lot for the quick response!
Cheers!

1 Like

I am just helping out on the forums, i am not the person to whom you should suggest bug fixes. I do not have that role or the necessary access to do anything about it

programming is time consuming, i recently spend 5 + 3 hours supervision from a senior developer to come to the conclusion that we needed to remove a single line of code.

This topic was automatically closed after 7 days. New replies are no longer allowed.