I don't want to type out every possible price combination but I've been searching for a long time and can't find a better way:
var selection = new Array (4);
selection[0] = new Array ('$210' 'etc', 'etc', 'etc', 'etc');
selection[1] = new Array ('Solar', 'Supernova', 'Quasar', 'Galaxy', 'Blackhole');
selection[2] = new Array ('Talk', 'Talk & Text', 'Talk, Text & Data');
selection[3] = new Array ('One Year', 'One', 'Two Years', 'Two', 'Three Years', 'Three', 'Four Years', 'Four');
function selectPhone () {
var yourPhone = prompt("What kind of Smartphone would you like: Solar: $100, Supernova: $200, Quasar: $300, Galaxy: $400, Blackhole: $500?");
if (yourPhone == selection[1][0]) {
console.log("You picked: " + yourPhone + "."), selectPlan ();
} else {
console.log("Error.");
}
}
function selectPlan () {
var yourPlan = prompt("What Plan Would You Like: Talk: $10, Talk & Text: $20 or Talk, Text & Data: $30?");
if (yourPlan == selection[2][0]) {
console.log("You picked: " + yourPlan + "."), selectTerm ();
} else {
console.log("Error.");
}
}
function selectTerm () {
var yourTerm = prompt("What Term Would You Like: One Year: $100, Two Years: $200, Three Years: $300 or Four Years: $400?");
if (yourTerm == selection[3][0] || selection [3][1]) {
console.log("You picked: " + selection[3][0] + ". \n Your total is: " + selection[0][0]);
} else {
console.log("Error.");
}
}
selectPhone ();
I can't figure out how to program it so it can just pick up the selections made and convert them to numeric values and perform simple addition on them. I'm a beginner so please explain everything. THANKS A LOT!!