+ 2
"20%" would be a string, you would need to convert it to a numeric type to do calculations with it
18th Apr 2022, 4:15 PM
Lisa
Lisa - avatar
+ 1
1.If you want to get output without using html go for alert(); 2.while taking input it is string by default so use parseInt(); to convert to int 3.tip calculation : put 100 in denominator /* let bill = parseInt(prompt("What's Your Bill?")); let tip = (bill * whatTip)/100; */ hope this helps!
18th Apr 2022, 4:26 PM
Himavanth
Himavanth - avatar
+ 1
let whatTip = prompt("What Type Of Tip Are You Looking for? 15% or 20%"); let bill = parseInt(prompt("What's Your Bill?")); if(whatTip === "20%") { let tip = (bill * 20)/100; alert("Your Tip is: "+ tip); bill=bill+tip; alert("You New Total is: "+ bill); } else if(whatTip == "15%") { let tip = (bill * 15)/100; alert("Your Tip is: "+ tip); bill=bill+tip; alert("You New Total is: "+ bill); } //Is this how you want it to work just check once in playground
18th Apr 2022, 4:39 PM
Himavanth
Himavanth - avatar