I’ve been challenged with building a tip calculator to test my knowledge of functions. My function seems to check out fine, however is there a reason I am unable run an array through my function and have is output a mutated array?
var base = [48, 124, 268];
function tipAmmount(base) {
if(base <= 50) {
var tip = base * .2;
return tip;
} else if (base > 50 && base <= 200) {
var tip = base * .15;
return tip;
} else {
var tip = base * .1;
return tip;
}
}
console.log(tipAmmount());
function tipAmmount(base) {
if(base <= 50) {
var tip = base * .2;
return tip;
} else if (base > 50 && base <= 200) {
var tip = base * .15;
return tip;
} else {
var tip = base * .1;
return tip;
}
}
var tips = [48, 124, 268].map(tipAmmount)
console.log(tips)