'does anyone know how to correct this code [closed]
function tipCalculator(nonTipTotal)
{
var totalWithTip = nonTipTotal * 15;
console.log(`You should pay {totalWithTip} including tip`)
}
function tipCalculator();
It's supposed to print out the statement of the total with the tip included
Solution 1:[1]
Maybe this?
function tipCalculator(nonTipTotal) {
const totalWithTip = nonTipTotal * 1.15;
console.log(`You should pay ${totalWithTip} including tip`)
}
const billTotal = 25 // get your bill input somehow - depends how this runs
tipCalculator(billTotal);
Solution 2:[2]
You are missing the $ symbol before the opening curly bracket. It should be ${totalWithTip} instead of {totalWithTip}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | see sharper |
| Solution 2 | Chris Lemus |
