<commit_before>'use strict';


var theScores = [];
var scoresTable = document.getElementById('highscores');

function HighScore (name, score){
  this.name = name;
  this.score = score;
  theScores.push(this);
};

new HighScore ('Adam', 800);
new HighScore ('Phil', 500);
new HighScore ('Lola', 600);
new HighScore ('Brandon', 700);

// function sortScores(){
//   orderedScores =
// };
theScores.sort(function(a, b){
  return b.score - a.score;
});

HighScore.prototype.render = function(){
  var trEl = document.createElement('tr');
  var tdEl = document.createElement('td');
  tdEl.textContent = this.name;
  trEl.appendChild(tdEl);

  tdEl = document.createElement('td');
  tdEl.textContent = this.score;
  trEl.appendChild(tdEl);

  scoresTable.appendChild(trEl);
};

function tableHeader(){
  var trEl = document.createElement('tr');

  var thEl = document.createElement('th');
  thEl.textContent = 'Name';
  trEl.appendChild(thEl);

  thEl = document.createElement('th');
  thEl.textContent = 'Score';
  trEl.appendChild(thEl);
  scoresTable.appendChild(trEl);
};

function tableScores(){
  for(var i = 0; i < theScores.length; i++){
    theScores[i].render();
  }
};


// if(local storage){
//   run function to add new scores to high score table
// } else {
//   load default high scores table
// }
tableHeader();
tableScores();
// allScores();
<commit_msg>started with local storage portion of high scores<commit_after>'use strict';

var newScore = [];
var theScores = [];
var scoresTable = document.getElementById('highscores');

function HighScore (name, score){
  this.name = name;
  this.score = score;
  theScores.push(this);
};

new HighScore ('Adam', 800);
new HighScore ('Phil', 500);
new HighScore ('Lola', 600);
new HighScore ('Brandon', 700);

function addScore(){

  theScores.push(newScore);
}

theScores.sort(function(a, b){
  return b.score - a.score;
});

HighScore.prototype.render = function(){
  var trEl = document.createElement('tr');
  var tdEl = document.createElement('td');
  tdEl.textContent = this.name;
  trEl.appendChild(tdEl);

  tdEl = document.createElement('td');
  tdEl.textContent = this.score;
  trEl.appendChild(tdEl);

  scoresTable.appendChild(trEl);
};

function tableHeader(){
  var trEl = document.createElement('tr');

  var thEl = document.createElement('th');
  thEl.textContent = 'Name';
  trEl.appendChild(thEl);

  thEl = document.createElement('th');
  thEl.textContent = 'Score';
  trEl.appendChild(thEl);
  scoresTable.appendChild(trEl);
};

function tableScores(){
  for(var i = 0; i < theScores.length; i++){
    theScores[i].render();
  }
};


if(localStorage){
  newScore = JSON.parse(localStorage.getItem('User.all'));
  addScore();
  tableHeader();
  tableScores();
  console.log('Storage available');
} else {
  tableHeader();
  tableScores();
}
// allScores();

{'fraction_non_alphanumeric': 0.16684340756451044, 'fraction_numerical': 0.009190526687875575, 'mean_word_length': 4.516569200779727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5164766', 'n_tokens_mistral': 986, 'n_tokens_neox': 923, 'n_words': 208}