Exercise on Objects in ES6
Now, we'll create a "Basket" object using the concepts of Objects.
We'll cover the following
Exercise 1:
Suppose an array of firstName
, email
, basketValue
triples are given. Create ONE JavaScript expression that puts a default value of '-'
and 0
to the firstName
or basketValue
fields respectively, whenever the firstName
or the basketValue
keys are missing. Remember to name your new object, newBaskets
or your code won’t run.
Get hands-on with 1400+ tech skills courses.