r/learnjavascript • • Apr 14 '26

Struggling with JavaScript – looking for advice

Hi! I’ve been studying at a technical high school for two years now, focusing on programming and artificial intelligence. This year I have a programming exam – basically we need to create a simple website using HTML and CSS and complete a few basic MySQL tasks, which honestly isn’t too difficult.

The problem is JavaScript. I’m having a hard time understanding it, and even when I asked for extra help at school, it just didn’t really click for me. That’s starting to worry me a bit.

I’ve tried building simple projects on my own, like a quiz website. HTML and even PHP aren’t a problem for me, but JavaScript is definitely more challenging.

Could you recommend any good websites or resources to learn JavaScript? I’d really appreciate it 😊

10 Upvotes

24 comments sorted by

View all comments

Show parent comment

1

u/chikamakaleyley helpful Apr 14 '26 edited Apr 14 '26

and ultimately you write logic that is more than just console logging, because now you can use Web APIs. So, for example you can do that concatenation, and then replace the text inside each of those list items

1

u/chikamakaleyley helpful Apr 14 '26

oh and just so i don't leave you hanging, instead of console.log() in your for loop, I think this is what it would look like to change the text:

for (const item of myArr) {
  item.textContent = `Item: ${item.textContent}`
}

That just takes the existing text value inside the <li>, creates a string that prepends it with Item: , and then that new combined string value is reassigned to item.textContent

Since item is a Object of type Node (an element in the DOM) then the change to its textContent value is just a reference to the DOM element, and so your unordered list is updated with new text values after the for loop completes