added docs
This commit is contained in:
1 parent
1dcb884552
commit
8acba51d27
17 files changed
+2213
-6
No files matched your search
@@ -0,0 +1,38 @@
|
||||
export class HockeyGame{
|
||||
constructor(){
|
||||
this.home = 0
|
||||
this.away = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when home team scores. It will
|
||||
* increase home team score by 1 point.
|
||||
*/
|
||||
homeTeamScores(){
|
||||
this.home += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this method when away team scores. It will
|
||||
* increase home team score by 1 point.
|
||||
*/
|
||||
awayTeamScores(){
|
||||
this.away += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns winner of the game.
|
||||
*
|
||||
* @returns {string} the name of the winner team. Either "home", "away" or "tie"
|
||||
*/
|
||||
winner(){
|
||||
if(this.home > this.away){
|
||||
return "home"
|
||||
}
|
||||
if(this.away > this.home){
|
||||
return "away"
|
||||
}
|
||||
return "tie"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
|
||||
/**
|
||||
* In statistics, infinity is set to 30.
|
||||
*/
|
||||
export const INFINITY = 30;
|
||||
|
||||
/**
|
||||
* Computes the average of the list. If the list is empty, the
|
||||
* function returns NaN
|
||||
* @param {number[]} lst
|
||||
* @returns the average of the list.
|
||||
*/
|
||||
export function average(lst){
|
||||
if(lst.length < 1){
|
||||
return NaN;
|
||||
@@ -14,6 +24,12 @@ export function average(lst){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes the standard deviation of the list. If the list is empty, the
|
||||
* function returns NaN
|
||||
* @param {number[]} lst
|
||||
* @returns the standard deviation of the list.
|
||||
*/
|
||||
export function std(lst){
|
||||
if(lst.length < 1){
|
||||
return NaN;
|
||||
|
||||
Reference in new issue
Block a user