Could anyone explain to me why I can’t get my array to fill with values when using a “normal” function script but I can when using the arrow function script?
I am a beginner and am trying to learn my way!
Function Script:
function tipAmountA (billValueB) {
if (billValueB >=50 && billValueB <=300) {
tipValue = billValueB * usualTip15
} else {
tipValue = billValueB * diffTip20
}
}
console.log (tipAmountA(10))
const billsArrayB = [40,299,301]
console.log (tipValue)
const tipsArrayB =[tipAmountA (billsArrayB[0]),tipAmountA (billsArrayB[1])]
console.log (billsArrayB, tipsArrayB)
Arrow Function Script:
function tipAmountB (billValueB) {
return billValueB >=50 && billValueB <=300 ? tipValue = billValueB * usualTip15 :
tipValue = billValueB * diffTip20
}
console.log (tipAmountB(10))
const billsArrayB = [40,299,301]
console.log (tipValue)
const tipsArrayB =[tipAmountB (billsArrayB[0]),tipAmountB (billsArrayB[1])]
console.log (billsArrayB, tipsArrayB)