Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- '10,12,14,13'
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- //here is the solution:
- const input = gets().split(',').map(el => +el);
- print(input);
- const length = input.length;
- let sum = 0;
- for (let index = 0; index < input.length; index++) {
- sum += input[index];
- }
- let average = sum / length;
- print(average.toFixed(2));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement