Arrays: Properties, Methods, and Manipulation
//var myArr = ['apple', 'barries', 'bannana', 'coke'];
// var indexOf = myArr.indexOf('coke');
// console.log(indexOf);
//Push into Array
// myArr.push('bread');
//Delete last item in array takes no pram
// myArr.pop();
//Unshift adds to beginning of array
//myArr.unshift('bob');
//Shift Deletes from beginning of array
//myArr.shift();
//Print Array to String
//var foo = myArr.toString();
//Foreach loop
// var myArr1 = [5, 10, 15, 2];
//forEach method
// function timeTen(element, index, array){
// array[index] = element * 10;
// }
// myArr1.forEach(timeTen);
//Array of objects
// var family = [
// {
// name: 'jude',
// age: 8
// },
// {
// name: 'allison',
// age: 32,
// },
// {
// name: 'cory',
// age: 39,
// },
// {
// name: 'caroline',
// age: 3
// }
// ]
// Foreach method
// function printFamily(element, index, array){
// console.log('name: '+ element.name +' , '+ 'age: ' + element.age);
// }
//family.forEach(printFamily);
//reverse items in a array
//myArr.reverse()
//Concat two arrays together
//var foo = ['butter', 'bread', 'coke', 'chips'];
// var foo2 =['cookies', 'water'];
// saving to varible
// var concat = foo.concat(foo2);
//Mixed pram's
//var mixedPrem = foo.concat(1,2,3,4,5);
//join method pass in any thing to be set in between values
//var join = foo.join(' -> ');
//Slice return only a portion of the array
//var sample = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
//It takes two pream a beginning index and an ending index
//var slice = sample.slice(9,15);
//Splice Deletes portions of an array
//var deleted = sample.splice(5,9);
//Orginal array running splice
// console.log(sample);
//items returned that were spliced
//console.log(deleted);
//Sorting numbers method
//var num = [1,2,4,20,21,22,19,10,33,56,110];
//Compare function (Can be custmoized)
//function sortNum(a,b){
//Ascending Order
//return a-b;
//Descending Order
//return b-a;
//}
// num.sort(sortNum);
// console.log(num);
//Sorting Strings
//var myArr = ['Helena','Iowa', 'Baton Rouge', 'Raleigh', 'Nashville','alberta', 'mobile'];
//compare function -Make sort Case Sensitive
// function sortAlph(a,b){
// var aLower = a.toLowerCase();
// var bLower = b.toLowerCase();
// if(aLower < bLower) return -1;
// if(aLower > bLower) return 1;
// return 0;
// }
// myArr.sort(sortAlph);
// console.log(myArr);