Algorithm Playground

Taking the algorithms from Coding Dojo's pre-bootcamp coursework and turning them into functional examples that users can play with and learn from. All functions are made without any pre-built JavaScript functions or methods except .push() and .pop(). View on GitHub.

1. Print 1 to 5,000

Description: This program can print all the numbers in consecutive order from 1 to 5,000.



2. Print Odd Numbers

Description: This program can print all the odd numbers from 1 to 5,000.



3. Print Sum of ODD Numbers

Description: This program can print the sum of all the odd numbers from 1 to 5,000,000



4. Find Max & Min

Description: Given an array with multiple values (e.g. [-3, 3, 5, 7]), this program will find and print the largest and smallest numbers in the array. Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be. This algorithm will find the "max" and "min" values in your array.



5. Find Average of Array

Description: Given an array with multiple values (e.g. [1,3,5,7,20]), this program will calculate the average of the values in the array. Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be.



6. Square the Values of an Array

Description: Given an array x (e.g. [1, 5, 10, -2]), this algorithm will square each value in the array. When the program is done, x should have values that have been squared (e.g. [1, 25, 100, 4]). Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be. Then sit back and watch the numbers in your array get squared!



7. Eliminate Negative Numbers

Description: Given an array x (e.g. [1,5, 10, -2]), this algorithm replaces any negative number in the array with the value of "0" (zero). When the program is done, x should have no negative values (e.g. [1, 5, 10, 0]). Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be. Those negative numbers will be transformed into zeros in a blink of an eye.



8. Number to String

Description: This program takes an array of numbers and replaces any number that's negative with a string called "Dojo". For example if array x = [-1, -3, 2] after the program is done array x will equal [Dojo, Dojo, 2]. Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be. Watch as your negative numbers are replaced by the word "Dojo".



9. Greater than Y

Description: This program takes an array and returns the number of values in that array whose value is greater than y. For example, if array x = [1, 3, 5, 7] and y = 3, after this program is run it will print 2 (since there are two values in the array whose value is greater than 3). Set a value for Y, then toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers can be.



10. Bubble Sort

Description: Given an array with multiple random numbers, write a program that will sort the numbers (with the smallest number on the left and the largest number on the right), using the bubble sort method. Toggle the drop-down menus below to set the size of the array (i.e. how many numbers it contains) and the range for how big your numbers will be. Watch as bubble sort works it's magic!





Algorithm Playground : View it on GitHub.