Last active
May 2, 2017 03:58
-
-
Save milanraai/a02d13bf7fd3f43ece1f121103d54b55 to your computer and use it in GitHub Desktop.
RA 1 - milan_rai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Part 1 | |
function capitalize(salesTeam) { | |
// loop through the salesteam object | |
// delare var getName to get the same object | |
// split the name object into a array | |
// use ChatAt to get the first letter of the object | |
// return the result | |
salesTeam.map(function(salesPerson) { | |
var getPerson = salesPerson.name; | |
getPerson['first'] = getPerson['first'][0].toUpperCase() + getPerson['first'].slice(1, getPerson['first'].length + 1); | |
getPerson['last'] = getPerson['last'][0].toUpperCase() + getPerson['last'].slice(1, getPerson['last'].length + 1); | |
}) | |
} | |
// Part 2 | |
function assert(expectedBehavior, descriptionOfCorrectBehavior) { | |
if (!expectedBehavior) { | |
console.log(descriptionOfCorrectBehavior); | |
} else { | |
console.log('test passed'); | |
} | |
} | |
console.log(expectedBehavior); | |
assert(expectedBehavior === descriptionOfCorrectBehavior, 'should capitalize the first letter of the first and last names'); | |
Part 3 | |
var averageTeamSales = function (salesTeam) { | |
// get sales Value of each person using map | |
// get total function | |
// get average function to calculate | |
// reduce it to a single number | |
var totalArr = []; | |
var salesAmt = salesTeam.map(function(salesPerson){ | |
totalArr.push(parseInt(salesPerson.sales)); | |
}) | |
console.log(salesAmt) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment