New to coding project.

Alright so I’m trying to have this code call a random food 3 times, but I keep getting “food1”, “food2”, or “food3”. This is a code.org based project not Arduino. Am I approaching this the wrong way?

var food1 = "1 Donut";
var food2 = "1 Sandwich";
var food3 = "1 Coffee";
var food4 = "1 Hashbrown";
newOrder();
function newOrder() {
  var randfood1 = "food" + randomNumber(1, 4);
  var randfood2 = "food" + randomNumber(1, 4);
  var randfood3 = "food" + randomNumber(1, 4);
  setText("receipt1", "Can I please have: \n" + randfood1 + "\n" + randfood2 + "\n" + randfood3);
}

Why are you looking at a code.org based project?

I have no idea what that means.

YoungsterSP:
his is a code.org based project not Arduino. Am I approaching this the wrong way?

You are asking your question on the wrong Forum. This is the Arduino Forum.

…R

Am I approaching this the wrong way?

Yes. In any compile language, variable names are replaced by addresses. You can not determine anything about the value of a variable with a given name, when no variable has a name.