Meal Maker


#1

My code seems to work, except the price printed is a number like ::Your meal is Frogs Legs, Master Burger, and Lava Cake/Ice Cream. The total price is 36.400000000000006.

getRandomDishFromCourse(courseName) {
let dishes = this._courses[courseName];
let randomIndex = Math.floor(Math.random() * dishes.length);
return dishes[randomIndex];
},
generateRandomMeal() {
let appetizer = this.getRandomDishFromCourse(‘appetizers’);
let main = this.getRandomDishFromCourse(‘mains’);
let dessert = this.getRandomDishFromCourse(‘desserts’);
let totalPrice = appetizer.price + main.price + dessert.price;
return Your meal is ${appetizer.name}, ${main.name}, and ${dessert.name}. The total price is ${totalPrice}.
How do I code a number with two decimal point number; 36.40


#2

easy:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed


#3

Thanks for the information, I will try


#4

I fixed it with the following code after let totalPrice = …;

let a = totalPrice.toFixed(2);
totalPrice = a;