You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ES6: Use Destructuring Assignment to Extract Values from Objects
constHIGH_TEMPERATURES={yesterday: 75,today: 77,tomorrow: 80};// Only change code below this lineconst[highToday,highTomorrow]=HIGH_TEMPERATURES;
ES6: Use Destructuring Assignment to Assign Variables from Objects
constHIGH_TEMPERATURES={yesterday: 75,today: 77,tomorrow: 80};// Only change code below this lineconst{today: highToday,tomorrow: highTomorrow}=HIGH_TEMPERATURES;
ES6: Use Destructuring Assignment to Assign Variables from Nested Objects
constLOCAL_FORECAST={yesterday: {low: 61,high: 75},today: {low: 64,high: 77},tomorrow: {low: 68,high: 80}};// Only change code below this lineconst{today: {low: lowToday,high: highToday}}=LOCAL_FORECAST;
ES6: Use Destructuring Assignment to Assign Variables from Arrays
leta=8,b=6;// Only change code below this line[a,b]=[b,a];
ES6: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
constsource=[1,2,3,4,5,6,7,8,9,10];functionremoveFirstTwo(list){// Only change code below this lineconst[a,b,...arr]=list;// Change this line// Only change code above this linereturnarr;}constarr=removeFirstTwo(source);
ES6: Use Destructuring Assignment to Pass an Object as a Function's Parameters
conststats={max: 56.78,standard_deviation: 4.34,median: 34.54,mode: 23.87,min: -0.75,average: 35.85};// Only change code below this lineconsthalf=({min, max})=>(max+min)/2.0;// Only change code above this line
ES6: Create Strings using Template Literals
constresult={success: ["max-length","no-amd","prefer-arrow-functions"],failure: ["no-var","var-on-top","linebreak"],skipped: ["no-extra-semi","no-dup-keys"]};functionmakeList(arr){// Only change code below this lineconstfailureItems=[];// Only change code above this linefor(leti=0;i<arr.length;i++){failureItems.push(`<li class="text-warning">${arr[i]}</li>`);}returnfailureItems;}constfailuresList=makeList(result.failure);
ES6: Write Concise Object Literal Declarations Using Object Property Shorthand
// Only change code below this lineconstbicycle={gear: 2,setGear(newGear){this.gear=newGear;}};// Only change code above this linebicycle.setGear(3);console.log(bicycle.gear);
ES6: Use class Syntax to Define a Constructor Function
// Only change code below this lineclassVegetable{constructor(name){this.name=name;}}// Only change code above this lineconstcarrot=newVegetable('carrot');console.log(carrot.name);// Should display 'carrot'
ES6: Use getters and setters to Control Access to an Object
// Only change code below this lineclassThermostat{constructor(fahrenheit){this.fahrenheit=fahrenheit;}gettemperature(){return(5/9)*(this.fahrenheit-32);}settemperature(celsius){this.fahrenheit=(celsius*9.0)/5+32;}}// Only change code above this lineconstthermos=newThermostat(76);// Setting in Fahrenheit scalelettemp=thermos.temperature;// 24.44 in Celsiusthermos.temperature=26;temp=thermos.temperature;// 26 in Celsius
ES6: Create a Module Script
<html><body>
<!-- Only change code below this line -->
<scripttype="module"src="index.js"></script>
<!-- Only change code above this line -->
</body></html>
import{uppercaseString,lowercaseString}from'./string_functions.js';// Only change code above this lineuppercaseString("hello");lowercaseString("WORLD!");
ES6: Use * to Import Everything from a File
// Only change code above this lineimport*asstringFunctionsfrom"./string_functions.js";stringFunctions.uppercaseString("hello");stringFunctions.lowercaseString("WORLD!");
ES6: Create an Export Fallback with export default
exportdefaultfunctionsubtract(x,y){returnx-y;}
ES6: Import a Default Export
importsubtractfrom"./math_functions.js";// Only change code above this linesubtract(7,4);
ES6: Create a JavaScript Promise (usually asynchronously)
constmakeServerRequest=newPromise((resolve,reject)=>{// responseFromServer represents a response from a serverletresponseFromServer;if(responseFromServer){// Change this lineresolve("We got the data");}else{// Change this linereject("Data not received");}});
ES6: Handle a Fulfilled Promise with then
constmakeServerRequest=newPromise((resolve,reject)=>{// responseFromServer is set to true to represent a successful response from a serverletresponseFromServer=true;if(responseFromServer){resolve("We got the data");}else{reject("Data not received");}});makeServerRequest.then(result=>{console.log(result);});
ES6: Handle a Rejected Promise with catch
constmakeServerRequest=newPromise((resolve,reject)=>{// responseFromServer is set to false to represent an unsuccessful response from a serverletresponseFromServer=false;if(responseFromServer){resolve("We got the data");}else{reject("Data not received");}});makeServerRequest.then(result=>{console.log(result);});makeServerRequest.catch(error=>{console.log(error);});
Think you