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
functionforecast(arr){// change code below this linearr=arr.slice(2,4);returnarr;}// do not change code below this lineconsole.log(forecast(['cold','rainy','warm','sunny','cool','thunderstorms']));
Spread Operator ...
functioncopyMachine(arr,num){letnewArr=[];while(num>=1){// change code below this linenewArr.push([...arr]);// change code above this linenum--;}returnnewArr;}// change code here to test different cases:console.log(copyMachine([true,false,true],2));
indexOf()
functionquickCheck(arr,elem){// change code below this linereturnarr.indexOf(elem)>0 ? true : false;// change code above this line}// change code here to test different cases:console.log(quickCheck(["squash","onions","shallots"],"mushrooms"));
For loop - Iterate Through all an Array
functionfilteredArray(arr,elem){letnewArr=[];// change code below this linefor(leti=0;i<arr.length;i++){letcount=0;for(letj=0;j<arr[i].length;j++){if(arr[i][j]!=elem){count++;}}if(count==arr[i].length){newArr.push(arr[i]);}}// change code above this linereturnnewArr;}// change code here to test different cases:console.log(filteredArray([[3,2,3],[1,6,3],[3,13,26],[19,3,9]],3));
Object
letfoods={apples: 25,oranges: 32,plums: 28};// change code below this linefoods.bananas=13;foods.grapes=35;foods.strawberries=27;// change code above this lineconsole.log(foods);
letuserActivity={id: 23894201352,date: 'January 1, 2017',data: {totalUsers: 51,online: 42}};// change code below this lineuserActivity.data.online=45;// change code above this lineconsole.log(userActivity);
letfoods={apples: 25,oranges: 32,plums: 28,bananas: 13,grapes: 35,strawberries: 27};// do not change code above this linefunctioncheckInventory(scannedItem){// change code below this linereturnfoods[scannedItem];}// change code below this line to test different cases:console.log(checkInventory("apples"));