2/7 madness


#1

Why is this happening?!? How this could be?!?
My code looks like this:
var cashRegister = {
total:0,
add: function(itemCost){
this.total += itemCost;
}
};

//call the add method for our items
cashRegister.add(0.89);
cashRegister.add(1.23);
cashRegister.add(4.99);
cashRegister.add(0.45);

//Show the total bill
console.log('Your bill is '+cashRegister.total);

And the result is:
Your bill is 7.5600000000000005

HOW???????
pls help!


#2

It's a simple computing error, others have experienced this on their lessons as well, and as long as the lesson passes I wouldn't worry about it.

Hope this helps! :+1:


#3

I know you abbreviated it, but please refrain from using curse words.


#4

I just cant pass this one, becouse of it... :confused: :frowning:


#5

The Eggs item cost is wrong.
var cashRegister = {
total:0,
add: function(itemCost){
this.total += itemCost;
}
};

//call the add method for our items
cashRegister.add(0.98);
cashRegister.add(1.23);
cashRegister.add(4.99);
cashRegister.add(0.45);

//Show the total bill
console.log('Your bill is '+cashRegister.total);


#6

I have this exact code, and it's printing the correct thing, but I keep getting the error "Oops, try again. Have you called the method four items to add each itemCost?" - it won't let me progress past this. Here is my code copied and pasted directly here:

var cashRegister = {
total:0,
add: function(itemCost){
this.total += itemCost;
}
};

//call the add method for our items
cashRegister.add(0.98);
cashRegister.add(1.23);
cashRegister.add(3.99);
cashRegister.add(0.45);

//Show the total bill
console.log('Your bill is '+cashRegister.total);


#7

lol, never mind! Stupidly, I got one of the prices wrong - 3.99 instead of 4.99, doh!