args
list within your function before determining that the element is or isn't there. Using something like .indexOf()
that gives you the answer in one shot is probably more efficient for this?
:star2: 2287 | @khaduch |http://www.freecodecamp.com/khaduch
function destroyer(arr) {
// Remove all the values
var args = [];
for(var i = 1; i < arguments.length; i++){
args.push(arguments[i]);
}
function destroy(element){
if(args.indexOf(element) != -1){
return element;
}
}
return arr.filter(destroy);
}
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
.indexOf
lookup...
:star2: 2288 | @khaduch |http://www.freecodecamp.com/khaduch
https://codepen.io/Mohammad_Hasham/pen/JbWOWw?editors=1010
actually i am comparing user generated pattern with computer generated pattern and storing them in an array for comparison.The problem is in the compareArray function might be some logic mistake.
@khaduch
What is wrong with this API call?
$(document).ready(function(){
var url = 'http://api.wunderground.com/api/myKey/geolookup/conditions/forecast/q/Canada/Toronto.json';
$.getJSON(url,function(data){
var request = JSON.parse(data);
console.log(request[0]);
});
})
Nothing logs to the console.