//add to table. function FurtherTierIsOkay(tier, scores, points) { var tiers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 50, 100, 500, 1000, 2000, 5000, 10000, 20000, 30000, 50000, ]; if (tier <= 1) { return true; } else { //Find the previous tier. var previousTier = -1; for (var i = 0; i < tiers.length; i++) { if (tiers[i] == tier) { previousTier = tiers[i - 1]; } } if (previousTier == -1) { console.log("Something weird happened...."); return false; //Something terrible happened. } else if (!scores[tier]) { return true; //It's okay since no score is submitted yet. } else { return points < scores[previousTier]; //If it's greater something's wrong... } } } function EndsWithZeroes(str) { var zeroCount = 0; var string = String(str); for (var i = 0; i < string.length; i++) { if (string[i] == "0") { zeroCount++; } else { zeroCount = 0; } } return zeroCount >= 2; } function ScoreIsSanitary(rank, name, description, points) { if (Number(rank) <= 20) { return true; } else { if ( EndsWithZeroes(name) || EndsWithZeroes(description) || EndsWithZeroes(points) ) { return false; } else { return true; } } } function numberWithCommas(x) { if (Number.isInteger(x)) { var num_parts = x.toString().split("."); num_parts[0] = num_parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return num_parts.join("."); } else { return x; } } exports.ScoreIsSanitary = ScoreIsSanitary exports.FurtherTierIsOkay = FurtherTierIsOkay exports.EndsWithZeroes = EndsWithZeroes