Skip to content

Instantly share code, notes, and snippets.

@lwebber
Created September 24, 2019 03:13
Show Gist options
  • Save lwebber/35ae35ff478863264b00e82304c43e24 to your computer and use it in GitHub Desktop.
Save lwebber/35ae35ff478863264b00e82304c43e24 to your computer and use it in GitHub Desktop.
https://repl.it/@wwebby1/Creating-arrays-drill-1
https://repl.it/@wwebby1/Adding-array-items-drills
https://repl.it/@wwebby1/Accessing-array-items-drill
https://repl.it/@wwebby1/Array-length-and-access-drill
https://repl.it/@wwebby1/Array-copying-I-drill
Copying II Drill (Repl.it broken)
function minusLastItem(array) {
return array.slice(0, array.length-1)
}
function copyFirstHalf(array) {
return array.slice(0, array.length/2 );
}
Squares drill
function squares(array) {
return array.map(x => x * x);
}
Greatest to Least drill
function greatestToLeast(array) {
array.sort();
return array.reverse();
}
Short Words drill
function shortWords(array) {
return array.filter(word => word.length < 5);
}
Divisible by 5 drill
function isDivBy5(num){
return num % 5 === 0;
}
function divisibleBy5(array) {
return array.find(isDivBy5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment