Skip to content

Instantly share code, notes, and snippets.

@dHelmgren
Created May 20, 2019 17:44
Show Gist options
  • Save dHelmgren/f4b17d88458ef2f9c4d1d5e82de249fe to your computer and use it in GitHub Desktop.
Save dHelmgren/f4b17d88458ef2f9c4d1d5e82de249fe to your computer and use it in GitHub Desktop.
Finished JS Translation From Ruby
const coffeePrice = function coffeePrice(isIced, size, flavorArray){
let price = 2.50;
if(size == 0){
;
} else if (size == 1) {
price += 1;
} else {
price *= 2;
}
if (isIced){
price += 0.75;
}
for(let i = 0; i < flavorArray.length; i++){
console.log(`pumping ${flavorArray[i]}`);
price += 0.50;
}
return price
}
console.log(coffeePrice(true,3,['vanilla','lemon']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment