Показать сообщение отдельно
  #4 (permalink)  
Старый 21.05.2012, 12:14
Новичок на форуме
Отправить личное сообщение для volkovics Посмотреть профиль Найти все сообщения от volkovics
 
Регистрация: 19.03.2012
Сообщений: 5

Собственно, я попробую описать более подробней.

Вот задача, целиком и полностью:

Lunch with Objects, Arrays and Functions

Now that we are keeping track of what we are eating, how about we add the amount of calories that each of these food items contain. To do this each item in our array will need to be an Object. The object will store the name and the calorie count of each food item in our array. Because it's all going to be a little different let's do this for lunch.

We have a pretty good start on this one all we need to do is push our name and calorie values into our lunch array. To do this define a variable called food and assign an object with the {} to it. This object is going to contain the name and calories arguments. Then push this food variable into our lunch array.

И к этому всему дан код, который нужно модифицировать, дабы он заработал:

var lunch = [];
var addLunchFood = function(name,calories){
    
};
addLunchFood('Burger',900);
addLunchFood('Fries',700);
addLunchFood('Soda',300);


Вот собственно и вся задача.


________________________________

Вообщем, вся ошибка заключалась в том, что нужно было в объекте указать вот так:

var food = {name:name, calories:calories};


Извиняюсь, что нафлудил.

Последний раз редактировалось volkovics, 21.05.2012 в 12:39.
Ответить с цитированием