Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MAD Monica#1

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mccr wants to merge1 commit intodanigpgo:master
base:master
Choose a base branch
Loading
frommccr:master
Open
Changes fromall 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
39 changes: 36 additions & 3 deletionsstarter-code/functions-and-arrays.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,9 +114,16 @@ console.log(uniqued);

// Finding Elements
function doesWordExist (wordsArray, word) {

var response = false;
wordsArray.forEach(function(w){
if (w === word) {
response = true;
}
});
return response;
}


var words = [
"machine",
"subset",
Expand All@@ -136,7 +143,13 @@ console.log(hasDog);

// Counting Repetion
function howManyTimes (words, word) {

var count = 0;
words.forEach(function(w){
if (w === word) {
count += 1;
}
});
return count;
}

var words = [
Expand All@@ -161,7 +174,27 @@ console.log(howManyDog);

// Bonus Quest
function greatestProduct (matrix) {

var greatest = 0;
var product, i,j;
//Horizontal
for(i = 0; i < 20; i++) {
for (j = 0; j < 17; j++) {
product = matrix[i][j]* matrix[i][j+1]* matrix[i][j+2] *matrix[i][j+3];
if(product > greatest) {
greatest = product;
}
}
}
//Vertical
for(i = 0; i < 17; i++) {
for (j = 0; j < 20; j++) {
product = matrix[i][j]* matrix[i+1][j]* matrix[i+2][j] *matrix[i+3][j];
if(product > greatest) {
greatest = product;
}
}
}
return greatest;
}

var matrix = [
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp