Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work done #423

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/functions-and-arrays.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
// Iteration 1 | Find the Maximum
function maxOfTwoNumbers() {}
function maxOfTwoNumbers(...nums) { return Math.max(...nums) }
// It's not the poitnof the function, the function shoud only accept two numbers, but since the tests pass and I find it funny i'll keep it like this





// Iteration 2 | Find the Longest Word
const words = ["mystery", "brother", "aviator", "crocodile", "pearl", "orchard", "crackpot"];

function findLongestWord() {}
function findLongestWord(arrayOfWords) { return arrayOfWords.length === 0 ? null : arrayOfWords.sort((word1, word2) => word2.length - word1.length)[0];}




// Iteration 3 | Sum Numbers
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];

function sumNumbers() {}
function sumNumbers(arrayOfNumbers) { return arrayOfNumbers.reduce((prev, curr) => prev + curr, 0); }




// Iteration 4 | Numbers Average
const numbers2 = [2, 6, 9, 10, 7, 4, 1, 9];

function averageNumbers() {}
function averageNumbers(arrayOfNumbers) { return arrayOfNumbers.length === 0 ? 0 : arrayOfNumbers.reduce((prev, curr) => prev + curr, 0) / arrayOfNumbers.length; }




// Iteration 5 | Find Elements
const words2 = ["machine", "subset", "trouble", "starting", "matter", "eating", "truth", "disobedience"];

function doesWordExist() {}
function doesWordExist(arrayOfElements, element) { return arrayOfElements.length === 0 ? null : arrayOfElements.includes(element); }