I am getting a failed test even though it looks like I am getting all of the expected output in the terminal. It looks like the output is all running together on one line.
Can anyone help me out with this?
It shows me this: FAILED Test Case: getPrices method applies tax when taxBoolean parameter is true Your Code Produced: Dish: Italian pasta Price: $ 11.46\nDish: Rice with veggies Price: $ 10.38\nDish: Chicken with potatoes Price: $ 18.66\nDish: Vegetarian Pizza Price: $ 7.74\nExpected Output Is: Dish: Italian pasta Price: $11.46 Dish: Rice with veggies Price: $10.38 Dish: Chicken with potatoes Price: $18.66 Dish: Vegetarian Pizza Price: $7.74
// Given variables
const dishData = [
{
name: "Italian pasta",
price: 9.55
},
{
name: "Rice with veggies",
price: 8.65
},
{
name: "Chicken with potatoes",
price: 15.55
},
{
name: "Vegetarian Pizza",
price: 6.45
},
]
const tax = 1.20;
// Implement getPrices()
function getPrices(taxBoolean) {
for (let i = 0; i < dishData.length; i++){
let finalPrice = 0;
if (taxBoolean == true) {
finalPrice = dishData[i].price * tax;
}
else if (taxBoolean == false) {
finalPrice = dishData[i].price;
}
else {
console.log("You need to pass a boolean to the getPrices call!");
return;
}
console.log("Dish: ", dishData[i].name, "Price: $", finalPrice);
}
}
// Implement getDiscount()
function getDiscount(taxBoolean, guests) {
getPrices(taxBoolean);
if (typeof guests === 'number' && guests > 0 && guests < 30) {
var discount = 0;
if (guests < 5) {
discount = 5;
}
else if (guests >= 5) {
discount = 10;
}
console.log('Discount is: $' + discount);
}
else {
console.log('The second argument must be a number between 0 and 30')
}
}
// Call getDiscount()
getDiscount(true, 2);
getDiscount(false, 2);
getDiscount(true, 20);
getDiscount();
getDiscount(true, 50);