Create a new JS Bin and solve each challenge, then send it to your mentor for review.
DO NOT leave your answers as comments here.
Create a new JS Bin and solve each challenge, then send it to your mentor for review.
DO NOT leave your answers as comments here.
// Forked from https://gist.github.com/philspitler/992d919e2834881e34d2e6754c586507 | |
// Write a function named greatestNumber that takes 2 arguments: | |
// 1 - (number) firstNum | |
// 2 - (number) secondNum | |
// the function returns the number with the greatest value |
// Forked from https://gist.github.com/philspitler/a61506604a3356f4cd92252b8ebe6866 | |
// Write a function named fullName that has 2 parameters: | |
// 1 - (string) firstName | |
// 2 - (string) lastName | |
// the function returns a string that is the firstName and lastName with a space in between |
// Forked from https://gist.github.com/philspitler/8af4091bbeff223937c9f48902ff372b | |
// Write a function named addToEach that takes 2 arguments: | |
// 1 - (array) numbers | |
// 2 - (number) amountToAdd | |
// the function adds the number passed into amountToAdd to each number in the numbers array | |
// the function returns an array of sums |
// Forked from https://gist.github.com/philspitler/7631b46b4375d38fa5c1f1fd83665352 | |
// Looping with Conditionals | |
// When looping over an array, learn how to only push on things that match a certain condition. | |
// Update the for loop in this function to add the current item to the aces array | |
// if it is equivalent to the string 'Ace'. | |
function onlyTheAces(arr) { | |
var aces = []; | |
for(var i = 0; i < arr.length; i++) { | |
// Add the current element to the aces array if it equals 'Ace'. | |
} | |
return aces; | |
} | |
console.log(onlyTheAces(['Ace', 'King', 'Queen', 'Jack', 'Ace'])); // should output ['Ace', 'Ace'] |