Skip to content

lab #3428

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
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

lab #3428

Changes from 1 commit
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
Prev Previous commit
lab done missing iteration 8
  • Loading branch information
YehosuaEs committed Nov 14, 2022
commit 392259baacf19b6cbd17c7944d99d5e4d789ea0f
46 changes: 40 additions & 6 deletions src/functions-and-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,21 @@ function uniquifyArray(array) {
}



/*
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-..-.-.-.-.-.-.-.-.-.-.-.-
*/
// Iteration #6: Find elements
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];

function doesWordExist() { }
function doesWordExist(array, word) {
return !array.length ? null : array.includes(word)
}

/*
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-..-.-.-.-.-.--.-.-.-.-.-.
*/



Expand All @@ -131,10 +141,16 @@ const wordsCount = [
'matter'
];

function howManyTimes() { }


function howManyTimes(array, word) {
repeatWord = 0;
for (const i of array) {
if (word == i) {
repeatWord++;
}
}
return !array.length ? 0 : repeatWord;

}
// Iteration #8: Bonus
const matrix = [
[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],
Expand All @@ -159,8 +175,26 @@ const matrix = [
[1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48]
];

function greatestProduct() { }
function greatestProduct(matrix) {
const areOne = (currentValue) => currentValue = 1;
let ones = []
let two = []
for (const array of matrix) {
if (array.every(areOne)) {
ones.push(1);
}
}
for (const array of matrix) {
if (array.every(areTwo)) {
two.push(2);
}
}

return 1;

}

console.log(greatestProduct(matrix));



Expand Down