freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../es6/use-destructuring-assignmen...

1.1 KiB

id title challengeType videoUrl localeTitle
587d7b89367417b2b2512b49 Use Destructuring Assignment to Assign Variables from Objects 1

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'assert(getTempOfTmrw(AVG_TEMPERATURES) === 79, "<code>getTempOfTmrw(AVG_TEMPERATURES)</code> should be <code>79</code>");'
  - text: ''
    testString: 'getUserInput => assert(getUserInput("index").match(/\{\s*tomorrow\s*:\s*tempOfTomorrow\s*}\s*=\s*avgTemperatures/g),"destructuring with reassignment was used");'

Challenge Seed

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

Solution

// solution required