JS Assessment FUN! Question 1

JS Assessment FUN! Question 1

by nickadeemus2002

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var a = 2;
console.log(a);










/*
*************************************************
Write a function to asynchronously iterate 
through and process the elements of a 
specified array.

REQUIREMENTS

~Your function should expect two parameters: 
the first being the array of items to process, 
and the second being a reference to an 
external function that should be called in 
order to process each item.

~The external function expects two parameters: 
the first being an item to process, and the second 
being a callback function that it will call once 
it has finished processing the item. The 
callback is important, because processing the 
item is asynchronous (eg. it may involve an 
AJAX request to a Web service). 

~You don't have to implement the external function, 
and it's not particularly relevant what it does 
with each item.

~Your implementation must be encapsulated inside 
a function. You may not write other functions 
outside of it.

~Your implementation must not be destructive 
to the items array parameter.
*****************************************************
*/
/*
function ProcessMyItem(idx){
    //do something at a later time
    //to process the index value
    console.log('processItem method');
    console.log(idx);
}


//FUNCTION: processItems
//-----------------------------------------------
//items: array to process
//-----------------------------------------------
//processItem: a reference to an 
//external function that should be called in 
//order to process each item.
function processItems (items,processItem) {
  // FILL THIS IN
    console.log('array to process');
    console.log(items);
    console.log('callback');
    console.log(processItem);
}

var kids = ['Makayla', 'Kathryn', 'Bella'];
processItems(kids, checkOnKids);
*/