# | function | description |
---|---|---|
1 | Get_1_to_255 | // Write a function that returns an array with all the numbers from 1 to 255. |
2 | Get_even_1000 | // Write a function that would get the sum of all the even numbers from 1 to 1000. You may use a modulus operator for this exercise. |
3 | Sum_odd_5000 | // Write a function that returns the sum of all the odd numbers from 1 to 5000. (e.g. 1+3+5+...+4997+4999) |
4 | Iterate_an_array | // Write a function that returns the sum of all the values within an array. (e.g. [1,2,5] returns 8, [-5,2,5,12] returns 14) |
5 | Find_max | // Given an array with multiple values, write a function that returns the maximum number in the array. (e.g. for [-3,3,5,7] max is 7) |
6 | Find_average | // Given an array with multiple values, write a function that returns the average of the values in the array. (e.g. for [1,3,5,7,20] average is 7.2) |
7 | Array_odd | // Write a function that would return an array of all the odd numbers between 1 to 50. (ex. [1,3,5, .... , 47,49]). Hint: Use 'push' method. |
8 | Greater_than_Y | // Given value of Y, write a function that takes an array and returns the number of values that are greater than Y. For example if arr = [1, 3, 5, 7] and Y = 3, your function will return 2. (There are two values in the array greater than 3, which are 5, 7). |
9 | Squares | // Given an array with multiple values, write a function that replaces each value in the array with the product of the original value multiplied by itself. (e.g. [1,5,10,-2] will become [1,25,100,4]) |
10 | Negatives | // Given an array with multiple values, write a function that replaces any negative numbers within the array with the value of 0. When the program is done the array should contain no negative values. (e.g. [1,5,10,-2] will become [1,5,10,0]) |
11 | Max/Min/Avg | // Given an array with multiple values, write a function that returns a new array that only contains the maximum, minimum, and average values of the original array. (e.g. [1,5,10,-2] will return [10,-2,3.5]) |
12 | Swap_values | // Write a function that will swap the first and last values of any given array. The default minimum length of the array is 2. (e.g. [1,5,10,-2] will become [-2,5,10,1]). |
13 | Number_to_string | // Write a function that takes an array of numbers and replaces any negative values within the array with the string 'Dojo'. For example if array = [-1,-3,2], your function will return ['Dojo','Dojo',2]. |
jupiterorbita / basic-13 Goto Github PK
View Code? Open in Web Editor NEWbasic 13 algorithms - written in JavaScript
License: MIT License