scrimba
Learn Modern JavaScript
Use Destructuring Assignment to Assign Variables from Objects
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Use Destructuring Assignment to Assign Variables from Objects
AboutCommentsNotes
Use Destructuring Assignment to Assign Variables from Objects
Expand for more info
index.js
run
preview
console
var voxel = {x: 3.6, y: 7.4, z: 6.54 };

var x = voxel.x; // x = 3.6
var y = voxel.y; // y = 7.4
var z = voxel.z; // z = 6.54

const { x : a, y : b, z : c } = voxel; // a = 3.6, b = 7.4, c = 6.54


const AVG_TEMPERATURES = {
today: 77.5,
tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
"use strict";
// change code below this line
const tempOfTomorrow = undefined; // change this line
// change code above this line
return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79
Console
[
"JAN"
,
"FEB"
,
"MAR"
,
"APR"
,
"MAY"
]
,
index.html
-2:55