Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
thecodingaviator on master
remove A (#31157) (compare)
undefined
[true, true, false, false, true, false, false, true, true].filter(function (x) { return x });
[23,1,6,12,17,3,2,5,19,86,87].filter(function (x) { return x % 2 === 0 });
function someArguments (name) {
console.log(name);
console.log(arguments);
return "Hello " + name;
}
someArguments("Joseph", "is", "an", "awesome", "guy", "so", "he", "thinks");
function destroyer(arr) {
var args = [].slice.call(arguments);
var slice = args.slice(1);
var join = slice.join(", ");
// slice = [2,3]
// arr = [1, 2, 3, 1, 2, 3]
// args = [[1, 2, 3, 1, 2, 3], 2, 3]
function filter(value) {
return value === join;
}
var seek = arr.filter(filter);
return seek;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
function findLongestWord(str) {
return str.split(" ").reduce(function(a,b) {
a.length > b.length ? a.length:b.length;
});
}
@Zaluth soooo applying that above example to ur code.. internally its doing
function filter(value) {
return value === join;
}
[1, 2, 3, 1, 2, 3].filter(filter);
return 1 === "2, 3"
return 2 === "2, 3"
etc.. on each iteration
and since that comparation return false.. it filter everything out returning a empty array
:star2: 4929 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm