While learning JavaScript and trying to solve a challenge question, my code keeps outputting 'undefined value'.
My code:
function paidAmount(bill){
var tipPercent
if (bill < 50){
tipPercent = 0.20;
}
else if (bill >= 50 && bill <=200){
tipPercent = 0.15;
}
else{
tipPercent = 0.10;
}
return bill * tipPercent;
}
var tip1 = console.log(paidAmount(124));
var tip2 = console.log(paidAmount(48));
var tip3 = console.log(paidAmount(268));
var tipTotal = [tip1, tip2, tip3];
console.log(tipTotal);
Output:
18.599999999999998
9.600000000000001
26.8
(3) [undefined, undefined, undefined]
console.log()
function always returnsundefined