juan field
asked on
regarding the code you wrote. I am new in JS . where does your code goes and how does it apply ? I think you wrote it down but i cant seem to understand just yet.
I had this question after viewing how can i test my code?.
function every(array, callbackFunction) {
var doesEveryElementMatch = true;
array.forEach(function(ele ment) {
doesEveryElementMatch = callbackFunction(element);
});
return doesEveryElementMatch;
}
// when i am going to test the question what is the callbackfunction i am supposed to write down?
function every(array, callbackFunction) {
var doesEveryElementMatch = true;
array.forEach(function(ele
doesEveryElementMatch = callbackFunction(element);
});
return doesEveryElementMatch;
}
// when i am going to test the question what is the callbackfunction i am supposed to write down?
I am sorry but I don't understand what you are asking? Is this a different question from the one in the other thread or are you asking a question about something in that thread? If the latter then please post to that thread directly. If this is a different question please state what your question is.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you change that every Function code to -
it offers a better chance of doing what the array Method does.
function every(array, callbackFunction) {
var doesEveryElementMatch = true;
array.forEach(function(element) {
if (doesEveryElementMatch)
doesEveryElementMatch = callbackFunction(element);
});
return doesEveryElementMatch;
}
it offers a better chance of doing what the array Method does.
ASKER
thank you slick812...
I just closed the var doesEveryElementMatch to true so i would be able to check the inspections. Really JS is a different taste to my palate .. i like it , just getting use to the rules.
I just closed the var doesEveryElementMatch to true so i would be able to check the inspections. Really JS is a different taste to my palate .. i like it , just getting use to the rules.
the more conventional javascript FOR loop for ARRAY elements access can sometimes be better (my opinion) than the array.forEach( ), because u can use the LOOP break; and continue; operations, which I could not get to work in the array.forEach( ) operations