Skip to content
Permalink
Browse files

works but kinda surprised

  • Loading branch information...
aisflat439 committed Jun 5, 2017
1 parent 93b2c5b commit d3230a9410ae3669aace643cd6529614b39a4919
Showing with 35 additions and 0 deletions.
  1. +30 −0 june/1_june.js
  2. +5 −0 may/30_may.js
@@ -0,0 +1,30 @@
'use strict';

function matchPattern(pattern, string) {
let match = true;
pattern = Array.from(pattern);
string = string.split(' ');

if (pattern.length === string.length) {
pattern.forEach((item, index) => {
let valueToMatch = string[index];
for (let i = 0; i < pattern.length; i++) {
if (pattern[i] === item && valueToMatch !== string[i]) {
match = false;
}
}
});
} else {
match = false;
}
return match;
}

console.log(`Next line should be true:`);
console.log(matchPattern(`abba`, `cat dog dog cat`));
console.log(`Next line should be true:`);
console.log(matchPattern(`abab`, `cat dog cat dog`));
console.log(`Next line should be false:`);
console.log(matchPattern(`babb`, `cat dog cat dog`));
console.log(`Next line should be false:`);
console.log(matchPattern(`abaa`, `cat dog cat dog`));
@@ -1,6 +1,10 @@
'use strict';

function removeMatchingValues(testArray, valueToRemove) {
if (!valueToRemove) {
return `${testArray}, No matching value was entered.`;
}

testArray = testArray.filter((item) => {
if (item !== valueToRemove) {
return item;
@@ -13,3 +17,4 @@ function removeMatchingValues(testArray, valueToRemove) {
console.log(removeMatchingValues([3, 6, 1, 3, 8, 8], 3));
console.log(removeMatchingValues([3, 6, 1, 3, 8, 8], 8));
console.log(removeMatchingValues([4, 2, 8, 4, 4, 2], 4));
console.log(removeMatchingValues([4, 2, 8, 4, 4, 2]));

0 comments on commit d3230a9

Please sign in to comment.
You can’t perform that action at this time.