I’ve been ripping my hair out with this. It seems to render only when it feels like it. When it does render, it doesnt update when I save it again. Here’s my code. Does anyone know why it isnt rendering?
When you post directly into the forum, characters get warped or go missing, so it is difficult to tell whether it is just a consequence of pasting into the forums or whether you have made a typo/mistake in the actual code of the exercise/project. For example, in the code you posted:
there seems to be a missing closing tag <img />, but I can’t tell if it is just because of copy/pasting. Properly formatted code (using backticks) will remove this ambiguity. There are a few other spots where similar ambiguity is evident.
I can see a few issues within your animalFacts expression.
Check to make sure your h1 elements are properly formatted and closed.
There is also a string in your ternary expression that might be causing an error.
This is probably not causing an error, but I would check the attributes. ariaLabel is named incorrectly.
Thanks for your help. I dont think it’s the ternary expression as I replaced this with a fixed string and it still didnt work. I tried it with the basic ‘Hello world’, too and it didnt always render.
On occasions when it did render, ie, when it said ‘hello world’, the next time it still said ‘hello world’ even though I’d changed the code.
I think it has to be either the import statements or some kind of browser setings issue. Is there a way of testing this on localhost anyone? I’ve put this on the back-burner for now,
There are more issues as addressed by @mtrtmk that stop your code from rendering properly. But this ternary is indeed a problem:
Unless the quotemarks aren’t invisible due to a lack of formatting, you have a string without quotemarks inside the JS injection, which is causing an error because it’s taken for a non existing variable with syntax errors (spaces).
Also, the h1 tag is broken as mentioned by @chip9119454969 . You do not close it and the title should be rendered as the content of the h1 tag, so a self closing tag is not an option here:
<h1>{title==='' ? 'Click an animal for a fun fact!' : title}</h1>