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

solution works but jasmine says "wrong" #326

Open
wants to merge 1 commit 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
77 changes: 62 additions & 15 deletions src/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,69 @@ const repeatedWords = [
"matter"
];

function howManyTimes() {}


function howManyTimes(wordsArray, wordRepeat) {

let wordTwice = 0;
for (i=0; i<wordsArray.length; i++){
if (
wordRepeat === wordsArray[i]){
wordTwice += 1;
}

}
return wordTwice;
};
console.log (howManyTimes(repeatedWords, "matter"));


// Iteration 2 | Number Sequence
function createSequence() {}
function createSequence(numbers) {
let numbersrow = [];
if (
numbers === 0 ){
numbersrow = [];
}
else {
for (let i=0; i <= numbers; i++){
numbersrow.push(i)
}
}
return numbersrow;

};
console.log (createSequence (7));





// Iteration 3 | Multiply for Each
const numbers = [1, 2, 5, 10, 13, 50];

function multiplyBy() {}




// Iteration 4 | Filter Out
function multiplyBy(numberArray,multiplier) {
let newArray = [];
numberArray.forEach(function(numbers){
newArray.push(numbers*multiplier);
});
return newArray;
}

console.log(multiplyBy(numbers, 3));

// Iteration 4 | Filter Out
const original = ["cat", "dog", "fish", "bird", "cat", "fish"];
const toRemove = ["cat", "dog"];

function filterOut() {}

function filterOut(original, toRemove) {
if (original.length === 0){
return null;
}
const filteredArray = original.filter(function(item){
return !toRemove.includes(item);
});
return filteredArray;
}
console.log(filterOut (original, toRemove));



Expand All @@ -56,9 +94,18 @@ const duplicateWords = [
"bring"
];

function uniquifyArray() {}


const duplicates = duplicateWords.filter((string, index) => duplicateWords.indexOf(string) !== index);

function uniquifyArray(duplicateWords, duplicates) {
if (duplicateWords.length === 0){
return null;
}
const filteredArray1 = duplicateWords.filter(function(item1){
return !duplicates.includes(item1);
});
return filteredArray1;
}
console.log(uniquifyArray (duplicateWords, duplicates));


// Bonus: Iteration 6 | Product of Adjacent Numbers
Expand Down