Preview:
//Outputs a number within the range of indexes
//return {integer} - index within the cereal data
function getRandomIndex() {
  var nameList = getColumn("Cereal Nutrition", "Name");
  var index = randomNumber(0, nameList.length - 1);
}

//returns name at that index
// index {integer} - location in list
// return {string} - name at that index
function getName(index) {
  var nameList = getColumn("Cereal Nutrition", "Name");
  var name = nameList [index];
  return name;
}
// Outputs the location of a image of the cereal box
// index {integer} - number of index of image you need
// picture {string} - image a
function getCerealImage(index) {
  var allPictures = getColumn("Cereal Nutrition", "Box Image");
  var picture = allPictures [index];
  return picture;
}

//Check Calories, Check True
function checkCalories(guess, index) {
  var correct = false;
  var allCalories = getColumn("Cereal Nutrition", "Calories");
  if (guess == allCalories [index]) {
    correct = true;
  }
  return correct;
}
// Compares calories guessed to cereal and counts matches
// guess {intger} - user input the amount calories
// count {integer} - number of other cereal with that many calories
function allCaloriesCheck(guess) {
  var allCalories = getColumn("Cereal Nutrition", "Calories");
  var count = 0;
  for (var i = 0; i < allCalories.length; i++) {
    if (guess == allCalories[i]) {
      count = count + 1;
    }
  }
  return count;
}
//Check Sugar, Check True
function checkSugar(guess, index) {
  var correct = false;
  var allSugar = getColumn("Cereal Nutrition", "Sugar");
  if (guess == allSugar [index]) {
    correct = true;
  }
  return correct;
}
//Comapres sugar guessed to cereal and counts matches
//guess (integer) - nurser input the amount of Sugar
//count (integer) - number of other cereal with that many Sugar
function allSugarCheck(guess) {
  var allSugar = getColumn("Cereal Nutrition", "Sugar");
  var count = 0;
  for (var i = 0; i < allSugar.length; i++) {
    if (guess == allSugar[i]) {
      count = count + 1;
    }
  }
  return count;

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter