Sirush's Random Quote Machine :)


Hi, what do you say about this :question: :slightly_smiling_face:

toooo much of unnecessary code in every part… check this out its not any kind of instruction , but smth to think abt :slight_smile:

Annestezia, thank you for attention. :wink:
But what you see unnecessary? In style or in JS? :slightly_smiling_face:

In general your approach does seem to have a lot of extra html that is not needed. Keeping all of that the same, you could at least reduce the repetitive code when creating the 10 click event handlers for the buttons.

for (let i=0; i < 10; i++) {
  document.querySelectorAll("button")[i].addEventListener("click", click);
}
1 Like

Its in every part: html css js, so its at approach level

  • notice how similar is ur code for every quote, you could create 1 box in html with a button, p and anything you want , output random quote there and add a desired class ,
  • in ur classes the only thing that changes is color, this could be a good place for some refactoring too)
  • as for js just like @RandellDawson said theres no need to write 10 event handlers

Programming is meant to automate things and make you write less but in more hmm inventive way
Imagine what if there were 1000 quotes :scream:
“Everything should be made as simple as possible, but not simpler.” :wink:

@RandellDawson I added the loop. It didn’t work before, :rofl: maybe i was wrote it with mistake. So, thank you very much! :+1:

@Annestezia I’m beginner and your advices important for me. Thank you a lot :wink:

1 Like

you will get there eventually, be strong , my friend :vulcan_salute: :smile: