-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Emiliano.Arreola.mex.wd-pt.apr-23 #3780
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
Open
xing-eram
wants to merge
2
commits into
ironhack-labs:master
Choose a base branch
from
xing-eram:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,179 @@ | ||
// Iteration #1: Find the maximum | ||
function maxOfTwoNumbers() {} | ||
function maxOfTwoNumbers(a, b) { | ||
if (a>b) | ||
return a; | ||
else if (a<b) | ||
return b; | ||
else (a==b) | ||
return a || b | ||
} | ||
maxOfTwoNumbers(); | ||
|
||
|
||
|
||
|
||
// Iteration #2: Find longest word | ||
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot']; | ||
|
||
function findLongestWord() {} | ||
function findLongestWord(arr) { | ||
let x = ""; | ||
if (arr.length === 0) return null; | ||
else { | ||
for (let i = 0; i < arr.length; i++) { | ||
if (x.length < arr[i].length) { | ||
x = arr[i]; | ||
} | ||
} | ||
} | ||
return x; | ||
} | ||
|
||
|
||
findLongestWord(); | ||
|
||
|
||
|
||
|
||
// Iteration #3: Calculate the sum | ||
// Iteration #3: Calculate the sum | ||
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; | ||
|
||
function sumNumbers() {} | ||
function sumNumbers (arr) { | ||
let sum = 0 | ||
if ( arr.length === 0) { | ||
return 0 | ||
} else | ||
for (let i=0; i<arr.length; i++) { | ||
sum += arr [i] | ||
} | ||
return sum; | ||
} | ||
|
||
|
||
sumNumbers(); | ||
|
||
// Iteration #3.1 Bonus: | ||
function sum() {} | ||
function sum(arr) { | ||
let x = 0 | ||
if ( x===0) { | ||
return 0 | ||
} | ||
else | ||
for (let i=0; i<arr.length; i++) { | ||
sum += arr [i] | ||
} | ||
return sum; | ||
} | ||
|
||
sum(); | ||
|
||
|
||
// Iteration #4: Calculate the average | ||
// Level 1: Array of numbers | ||
const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9]; | ||
|
||
function averageNumbers() {} | ||
function averageNumbers(arr) { | ||
let avg = 0 | ||
if (arr.length === 0 ) { | ||
return null } | ||
else { | ||
for (i=0; i< arr.length; i++){ | ||
avg += arr[i]; | ||
|
||
} | ||
return avg/arr.length | ||
|
||
} | ||
} | ||
|
||
averageNumbers(); | ||
|
||
|
||
// Level 2: Array of strings | ||
const wordsArr = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace']; | ||
|
||
function averageWordLength() { } | ||
function averageWordLength(arr) { | ||
let avg = 0 | ||
if (arr.length === 0 ) { | ||
return null } | ||
else { | ||
for (i=0; i< arr.length; i++){ | ||
avg += arr[i].length; | ||
} | ||
return avg/arr.length | ||
|
||
} | ||
} | ||
averageWordLength(); | ||
|
||
|
||
|
||
// Bonus - Iteration #4.1 | ||
function avg() {} | ||
|
||
// Iteration #5: Unique arrays | ||
Expand All | ||
const wordsUnique = [ | ||
'crab', | ||
'poison', | ||
'contagious', | ||
'simple', | ||
'bring', | ||
'sharp', | ||
'playground', | ||
'poison', | ||
'communion', | ||
'simple', | ||
'bring' | ||
]; | ||
|
||
function uniquifyArray() {} | ||
function uniquifyArray(arr) { | ||
|
||
if ( arr.length === 0 ) { | ||
return null; } | ||
let array2 =[]; | ||
for ( let i= 0; i<arr.length; i++) { | ||
if (array2.indexOf(arr[i]) === -1) { | ||
array2.push(arr[i]); | ||
} | ||
} | ||
return array2; | ||
} | ||
uniquifyArray(); | ||
|
||
|
||
|
||
// Iteration #6: Find elements | ||
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience']; | ||
const wordsFind = [ | ||
"machine", | ||
"subset", | ||
"trouble", | ||
"starting", | ||
"matter", | ||
"eating", | ||
"truth", | ||
"disobedience", | ||
]; | ||
|
||
function doesWordExist(arr, bob) { | ||
if (arr.length > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a blocker but where is bob comming from ? |
||
return arr.includes(bob); | ||
} else { | ||
return null; | ||
} | ||
} | ||
doesWordExist(); | ||
|
||
function doesWordExist() {} | ||
|
||
|
||
|
||
// Iteration #7: Count repetition | ||
const wordsCount = [ | ||
'machine', | ||
'matter', | ||
'subset', | ||
'trouble', | ||
'starting', | ||
'matter', | ||
'eating', | ||
'matter', | ||
'truth', | ||
'disobedience', | ||
|
||
Expand All | ||
const wordsCount = [ | ||
'matter' | ||
]; | ||
|
||
function howManyTimes() {} | ||
function howManyTimes(arr, bob) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
let times = 0; | ||
|
||
for (i = 0; i < arr.length; i++) { | ||
if (arr[i] === bob) { | ||
times++; | ||
} | ||
} | ||
return times | ||
} | ||
howManyTimes(); | ||
|
||
|
||
// Iteration #8: Bonus | ||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice movee 🔥