This is an object John my prof. created, however I didn't clearly understand what 'this' means, and why an empty array was created before the for loop.
var john = {
fullName: 'John Smith',
bills: [124, 48, 180, 42],
calcTips: function (){
this.tips = [];
this.finalValues = [];
for(var i=0;i<this.bills.length;i++){
var percentage;
var bills = this.bills[i];
if(bills<50){
percentage = 0.2;
}
else if(bills<200&&bills>50){
percentage = 0.15;
}
else{
percentage = 0.1;
}
// Adds results to array
this.tips[i] = bills * percentage;
this.finalValues[i] = bills + (bills*percentage);
}
}
}