Vous êtes sur la page 1sur 2

function average(array) {

function plus(a, b) { return a + b; }


return array.reduce(plus) / array.length;
}
// Your code here.
//construct group by century
function groupBy(array, centuryFn){
var groups={};
array.forEach(function(person){
var century = centuryFn(person);
if(groups[century]){
groups[century].push(person.died-person.born);
}else{
groups[century]= (person.died-person.born);
}
});
retun groups;
}
//find the century each person belongs to.
var byCentury = groupBy(ancestry,function(person){
return Math.ceil(person.died/100);
});
//compute the average for each century in the century group
for(var century in byCentury){
console.log("The average age of "+century+"is"+average(century);)
}
// ? 16: 43.5
// 17: 51.2
// 18: 52.8
// 19: 54.8
// 20: 84.7
// 21: 94
***************************************8
function every(array, predicate) {
for (var i = 0; i < array.length; i++) {
if (!predicate(array[i]))
return false;
}
return true;
}
function some(array, predicate) {
for (var i = 0; i < array.length; i++) {
if (predicate(array[i]))
return true;
}
return false;
}

**************************************

API key
=======
AIzaSyBQtb_O7jIEWie5v6qm9MbHyTSjyKVIOjw

***************************************

<li class="gallery-item">
<a href="#"><img src="./images/p
eriyava-1.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/p
eriyava-2.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/S
AR-1.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/S
AR-2.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/p
eriyava-1.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/p
eriyava-2.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/S
AR-1.jpg"></a>
</li>
<li class="gallery-item">
<a href="#"><img src="./images/S
AR-2.jpg"></a>
</li>
100006547628865
C:\Users\kirthi\AppData\Roaming\Skype\chocolate.bar7\media_messaging\media_cache
_v3