DEV Community

Discussion on: A question from a Rookie to all the JavaScript Marvels out there

Collapse
 
yaphi1 profile image
Yaphi Berhanu • Edited

Nice work so far! The reason it's tough to find code to do what's asked is that there are a lot of pieces rolled into one.

Here's a breakdown of the pieces:

  • Hold a list of high scores (use an array, possibly with objects if you want to have a name and a score for each)
var highScores = [
    {name: 'alice', score: 9001},
    {name: 'bob', score: 9000},
    {name: 'corey', score: 200}
];
  • Enter name (get value of html input tag when submit button is clicked)

  • Put the latest score in, sort the array, and remove the bottom item (this can be optimized, but start with whatever method works for you)

  • If you want to keep track of the scores in the user's browser after they leave the page, use window.localStorage

I hope this helps!

I recommend starting with Max's explanation before this one though.

Collapse
 
mowglite profile image
Glen McLean

Thanks a million. yes I have started reading up on what Max said and the links he gave me to go check out and trying to put it together. That's what I was wanting realy didn't mean to imply that I was wanting the actual code for it because then I wouldn't learn much, just needed to know realy what the heck I should look for, thanks for that last point I'll definitely go read up about window.localstorage, did not think about that at all.

Collapse
 
yaphi1 profile image
Yaphi Berhanu

Glad it was helpful!