Question: I have set up new project in web api2 and as a framework, I want to use angular2. I configured project and add there quick start Angular. 

After running Home Page I saw what was expected. When I added new component and called it instead of `app.component`, I got a few errors in console. I looked up how to resolve my problem but nothing helped me. 

This is the error which I get in console
[![error](https://i.imgur.com/QcM1Eij.png)](https://i.imgur.com/QcM1Eij.png)

I have now idea what is wrong in this case.

Answer: 
I think its in the scope of simple javascript.

If you have your data in an array just use a simple iteration on it and compare the visit of current day to the visits from previous day.

A very simple solution might be:

```js
var visitsArr = [38,29,18,29,28,18,24];

checkVisitsDiff(visitsArr);

function checkVisitsDiff(arr){
  //Input validation check 
  if(!arr || arr.length <2){
     throw "Bad input!";
  }

  //If input is ok - Start from second element
  for(var i=1; i<arr.length; i++){
      var currentElement  = arr[i];
      var previousElement = arr[i-1];
      console.log("The difference from visit " + i + " to visit " +(i-1) + " is: " +(currentElement-previousElement));
  }
}
```

I hope this what you asked.
Use Array methods:

```js
var visitsArr = [38,29,18,29,28,18,24];

var diffs = visitsArr.slice(1).map((x,i)=> x-visitsArr[i]);

diffs.forEach((x,i) => console.log(
   `Visits from day ${i+1} to day ${i+2} increased by ${x}`
));
```

For more information, see

* [MDN JavaScript Reference - Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
* [MDN JavaScript Reference - Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
* [MDN JavaScript Reference - Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)