├── .gitignore ├── basic ├── 02-get-sum │ ├── get-sum.js │ ├── get-sum-run.js │ ├── get-sum.test.js │ └── readme.md ├── 01-hello-world │ ├── helloWorld.js │ ├── hello-world-run.js │ ├── hello-world.test.js │ └── readme.md ├── 05-find-max-number │ ├── find-max.js │ ├── find-max-run.js │ └── find-max.test.js ├── 03-calculator │ ├── calculator-run.js │ ├── calculator.test.js │ ├── calculator.js │ └── readme.md ├── 04-count-occurences │ ├── count-occurences-run.js │ ├── count-occurences.test.js │ ├── count-occurences.js │ └── readme.md ├── 06-reverse-a-number │ ├── reverse_number.test.js │ ├── reverse_a_number_run.js │ └── reverse_a_number.js ├── 07-move-zeros-to-end │ ├── move_zeros_to_end_run.js │ ├── move_zeros_to_end.js │ ├── move_zeros_to_end.test.js │ └── README.md ├── 08-move-array-d-places │ ├── move_array_d_places_run.js │ ├── README.md │ ├── move_array_d_places.js │ └── move_array_d_places.test.js ├── 11-intersection-of-two-sorted-array │ ├── intersection_of_two_sorted_arrays_run.js │ ├── intersection_of_two_sorted_arrays.test.js │ └── intersection-of-two-sorted-array.js ├── 09-count-max-number-of-ones │ ├── count_max_ones_run.js │ ├── count_max_ones.js │ └── count_max_ones.test.js └── 10-union-of-two-sorted-arrays │ ├── union_of_two_sorted_array_run.js │ ├── union_of_two_sorted_array.test.js │ └── union_of_two_sorted_array.js ├── index.txt ├── hackerank ├── solveMeFirst │ ├── READ.md │ ├── readme.md │ └── solveMeFirst.js └── simpleArraySum │ ├── simpleArraySum.js │ └── readme.md ├── random ├── filter.js ├── reducer.js └── map.js ├── package.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store -------------------------------------------------------------------------------- /basic/02-get-sum/get-sum.js: -------------------------------------------------------------------------------- 1 | function getSum(a, b) { 2 | return a + b; 3 | } 4 | 5 | module.exports = getSum; 6 | -------------------------------------------------------------------------------- /basic/01-hello-world/helloWorld.js: -------------------------------------------------------------------------------- 1 | function helloWorld() { 2 | return 'Hello world!'; 3 | } 4 | 5 | module.exports = helloWorld; 6 | -------------------------------------------------------------------------------- /basic/02-get-sum/get-sum-run.js: -------------------------------------------------------------------------------- 1 | const getSum = require('./get-sum'); 2 | 3 | const result = getSum(1, 2); 4 | 5 | console.log(result); 6 | -------------------------------------------------------------------------------- /basic/05-find-max-number/find-max.js: -------------------------------------------------------------------------------- 1 | function findMaxNunber(arr) { 2 | return Math.max(...arr); 3 | } 4 | 5 | module.exports = findMaxNunber; 6 | -------------------------------------------------------------------------------- /basic/01-hello-world/hello-world-run.js: -------------------------------------------------------------------------------- 1 | const helloWorld = require('./helloWorld'); 2 | 3 | const result = helloWorld(); 4 | 5 | console.log(result); 6 | -------------------------------------------------------------------------------- /basic/03-calculator/calculator-run.js: -------------------------------------------------------------------------------- 1 | const calculator = require('./calculator'); 2 | 3 | const result = calculator(19, 4.000899938383, '/'); 4 | 5 | console.log(result); 6 | -------------------------------------------------------------------------------- /basic/04-count-occurences/count-occurences-run.js: -------------------------------------------------------------------------------- 1 | const countOccurrences = require('./count-occurences'); 2 | 3 | const result = countOccurrences(111000, 0); 4 | 5 | console.log(result); 6 | -------------------------------------------------------------------------------- /basic/05-find-max-number/find-max-run.js: -------------------------------------------------------------------------------- 1 | const findMaxNunber = require('./find-max'); 2 | 3 | const result = findMaxNunber([1, 3, 4, 5, 5, 7, 20]); 4 | 5 | console.log(result); 6 | 7 | // works soo well. -------------------------------------------------------------------------------- /index.txt: -------------------------------------------------------------------------------- 1 | init () -> January 4th, 2024. 2 | 3 | 4 | Let's become a better developer!⚡ 5 | 6 | Questions? 7 | 8 | 9 | Fuck my phone on spoil. 10 | 11 | 12 | fuck my pc spoilt now 13 | 14 | 15 | lmao 16 | 17 | brooo -------------------------------------------------------------------------------- /basic/01-hello-world/hello-world.test.js: -------------------------------------------------------------------------------- 1 | const helloWorld = require('./helloWorld'); 2 | 3 | test(`Returning 'Hello World' as a string`, () => { 4 | const result = helloWorld(); 5 | expect(result).toBe('Hello world!'); 6 | }); 7 | -------------------------------------------------------------------------------- /basic/05-find-max-number/find-max.test.js: -------------------------------------------------------------------------------- 1 | const findMaxNunber = require('./find-max'); 2 | 3 | test('should log the highest number in the array ', () => { 4 | expect(findMaxNunber([1, 2, 3, 4, 5, 6, 7, 8, 88, 100])).toBe(100); 5 | }); 6 | -------------------------------------------------------------------------------- /basic/02-get-sum/get-sum.test.js: -------------------------------------------------------------------------------- 1 | const getSum = require('./get-sum'); 2 | 3 | test('should return the sum of two numbers', () => { 4 | const num1 = 1; 5 | const num2 = 2; 6 | 7 | const result = getSum(num1, num2); 8 | expect(result).toBe(3); 9 | }); 10 | -------------------------------------------------------------------------------- /hackerank/solveMeFirst/READ.md: -------------------------------------------------------------------------------- 1 | ## HOW THE PROGRAM WORKS 2 | - Enter each number by typing a number literal and hitting enter or return. 3 | - Type "calculate" to prompt the program to calculate the final sum of all the numbers previoulsy entered. 4 | 5 | ### FEATURES 6 | - handle invalid input. -------------------------------------------------------------------------------- /basic/06-reverse-a-number/reverse_number.test.js: -------------------------------------------------------------------------------- 1 | const reverseANumber = require("./reverse_a_number"); 2 | let testNum = 4378689736 3 | describe("reverse a number passed to the reverseANumber function", ()=>{ 4 | test("should return the reverse of a number", ()=>{ 5 | expect(reverseANumber(testNum)).toBe(6379868734); 6 | }) 7 | }) -------------------------------------------------------------------------------- /basic/07-move-zeros-to-end/move_zeros_to_end_run.js: -------------------------------------------------------------------------------- 1 | const zero_to_end = require("./move_zeros_to_end") 2 | 3 | const arr1 = [1, 2, 0, 0, 3, 4, 5, 6, 7, 8, 0, 0, 15, 12, 13, 0, 3, 4]; 4 | const arr2 = [0, 0, 1, 2, 3]; 5 | const arr3 = [1, 3, 7, 9, 0, 0, 0] 6 | 7 | console.log(zero_to_end(arr1)); 8 | console.log(zero_to_end(arr2)); 9 | console.log(zero_to_end(arr3)); -------------------------------------------------------------------------------- /basic/04-count-occurences/count-occurences.test.js: -------------------------------------------------------------------------------- 1 | const countOccurrences = require('./count-occurences'); 2 | 3 | test('should check through input string and check the count of the number of character in the string', () => { 4 | expect(countOccurrences('hello', 'l')).toBe(2); 5 | expect(countOccurrences('Victoria', 'e')).toBe(0); 6 | expect(countOccurrences('bless up', 'u')).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /random/filter.js: -------------------------------------------------------------------------------- 1 | const numbers = [1, -1, 2, -2, 3, 4]; 2 | 3 | // filter only the positive numbers 4 | 5 | const filteredPositive = numbers.filter((num) => num >= 0); 6 | 7 | console.log(filteredPositive); 8 | 9 | // filter only the negative numbers 10 | 11 | const filteredNegative = numbers.filter((num) => { 12 | return num <= 0; 13 | }); 14 | 15 | console.log(filteredNegative); 16 | -------------------------------------------------------------------------------- /basic/06-reverse-a-number/reverse_a_number_run.js: -------------------------------------------------------------------------------- 1 | const reverseANumber = require("./reverse_a_number"); 2 | let num1 = 12345; 3 | let num2 = 246810; 4 | let num3 = 357913117; 5 | 6 | 7 | console.log(`the reverse of ${num1} is: ${reverseANumber(num1)}`); 8 | console.log(`the reverse of ${num2} is: ${reverseANumber(num2)}`); 9 | console.log(`the reverse of ${num3} is: ${reverseANumber(num3)}`); 10 | -------------------------------------------------------------------------------- /basic/08-move-array-d-places/move_array_d_places_run.js: -------------------------------------------------------------------------------- 1 | const moveArrDplaces = require("./move_array_d_places"); 2 | 3 | let arr = [1, 2, 3, 4, 5, 6] 4 | let n = arr.length; 5 | 6 | for (let i = 0 + 1; i < n; ++i) { 7 | //moving the array d-places. 8 | let d = i; 9 | console.log(`The arr ${JSON.stringify(arr)} moved ${d}-place is: ${JSON.stringify(moveArrDplaces(arr, d))}`); 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "panthreon", 3 | "version": "1.0.0", 4 | "description": "becoming a better and world class software engineer.", 5 | "scripts": { 6 | "test": "jest" 7 | }, 8 | "author": "VickyJay", 9 | "license": "MIT", 10 | "devDependencies": { 11 | "jest": "^29.6.1" 12 | }, 13 | "dependencies": { 14 | "-": "^0.0.1", 15 | "npm": "^10.3.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /basic/11-intersection-of-two-sorted-array/intersection_of_two_sorted_arrays_run.js: -------------------------------------------------------------------------------- 1 | const intersection_of_two_sorted_arrays = require("./intersection-of-two-sorted-array"); 2 | 3 | const arr1 = [0, 3, 5, 6, 8, 11, 13, 14, 15, 19]; 4 | const arr2 = [0,1, 3, 8, 13, 19]; 5 | 6 | console.log(`The intersection of arr1: ${JSON.stringify(arr1)} and arr2: ${JSON.stringify(arr2)} is: `, intersection_of_two_sorted_arrays(arr1, arr2)); -------------------------------------------------------------------------------- /hackerank/simpleArraySum/simpleArraySum.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Complete the 'simpleArraySum' function below. 3 | * 4 | * The function is expected to return an INTEGER. 5 | * The function accepts INTEGER_ARRAY ar as parameter. 6 | */ 7 | 8 | function simpleArraySum(ar) { 9 | // Write your code here 10 | let total = 0; 11 | 12 | for (const num of ar) { 13 | total += num; 14 | } 15 | 16 | return total; 17 | } -------------------------------------------------------------------------------- /basic/09-count-max-number-of-ones/count_max_ones_run.js: -------------------------------------------------------------------------------- 1 | const count_max_ones = require("./count_max_ones"); 2 | 3 | const testArr = [ 4 | [1, 1, 0, 0, 0, 1, 1, 1], 5 | [1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1], 6 | [1, 0, 1, 1, 1, 1, 1], 7 | [1, 1, 1, 1, 0, 0, 1, 1] 8 | ] 9 | 10 | testArr.forEach(arr => { 11 | console.log(`max number of ones in the array: ${JSON.stringify(arr)} -> `, count_max_ones(arr)); 12 | }) -------------------------------------------------------------------------------- /basic/06-reverse-a-number/reverse_a_number.js: -------------------------------------------------------------------------------- 1 | 2 | function reverseANumber(num) { 3 | let reversedNumber = 0; 4 | 5 | while (num !== 0) { 6 | //get the last digit of the number 7 | let lastDigit = num % 10; 8 | //get the updated number without the last digit. 9 | num = Math.floor(num / 10); 10 | reversedNumber = (reversedNumber * 10 )+ lastDigit; 11 | } 12 | return reversedNumber; 13 | } 14 | 15 | module.exports = reverseANumber; -------------------------------------------------------------------------------- /hackerank/solveMeFirst/readme.md: -------------------------------------------------------------------------------- 1 | Complete the function solveMeFirst to compute the sum of two integers. 2 | 3 | Example 4 | 5 | Return 10. 6 | 7 | Function Description 8 | 9 | Complete the solveMeFirst function in the editor below. 10 | 11 | solveMeFirst has the following parameters: 12 | 13 | int a: the first value 14 | int b: the second value 15 | Returns 16 | 17 | - int: the sum of and 18 | 19 | Constraints 20 | 21 | Sample Input 22 | 23 | a = 2 24 | b = 3 25 | Sample Output 26 | 27 | 5 28 | Explanation 29 | -------------------------------------------------------------------------------- /basic/08-move-array-d-places/README.md: -------------------------------------------------------------------------------- 1 | ### How does the function move_array_d_places work? 2 | 3 | - The function moveArrayDplaces() accepts two parmaeters an ```arr```, that would be rotated and a ```number```, that indicates the position the array will be rotated by. 4 | - The array is rotated from left to right, starting from the ```number``` passed as the second parameter. 5 | - We use a modulo operator to ensure that the passed number falls within the index of the array to be rotated. 6 | - The array is returned after it is rotated. -------------------------------------------------------------------------------- /basic/10-union-of-two-sorted-arrays/union_of_two_sorted_array_run.js: -------------------------------------------------------------------------------- 1 | const union_of_two_sorted_array = require("./union_of_two_sorted_array"); 2 | 3 | const testArr1 = [[1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]]; 4 | const testArr2 = [[13, 15, 17, 19, 21, 23, 27, 29], [12, 14, 16, 18, 20, 25, 26, 30]] 5 | 6 | 7 | console.log(`the union of testArr1: ${JSON.stringify(testArr1)} is: `, union_of_two_sorted_array(testArr1[0], testArr1[1])); 8 | console.log(`the union of testArr2: ${JSON.stringify(testArr2)} is: `, union_of_two_sorted_array(testArr2[0], testArr2[1])); 9 | -------------------------------------------------------------------------------- /basic/03-calculator/calculator.test.js: -------------------------------------------------------------------------------- 1 | const calculator = require('./calculator'); 2 | 3 | test('should calculate the arithmetic of two inputs data correctly', () => { 4 | const num1 = 7; 5 | const num2 = 2; 6 | 7 | // addition fx 8 | expect(calculator(num1, num2, '+')).toBe(9); 9 | 10 | // subtraction fx 11 | expect(calculator(num1, num2, '-')).toBe(5); 12 | 13 | // multiplication fx 14 | 15 | expect(calculator(num1, num2, '*')).toBe(14); 16 | 17 | // division fx 18 | 19 | expect(calculator(num1, num2, '/')).toBeCloseTo(3.5); 20 | }); 21 | -------------------------------------------------------------------------------- /random/reducer.js: -------------------------------------------------------------------------------- 1 | const numbers = [1, -1, 2, -2, 3, 4]; 2 | 3 | // NOTE things happening behind the scene - add the acc value to to the value 4 | 5 | // lets shorten acc = a and cur = c 6 | // a = 0, c = 1 => a = 1 7 | // a = 1, c = 0 => a = 0 8 | // a = 0, c = 2 => 1 a= 0 9 | 10 | // the first four values on the array will yield 0 so we can add the last two and get 7 11 | 12 | const sum = numbers.reduce((acc, cur) => { 13 | return acc + cur; 14 | }, 0); 15 | 16 | console.log(sum); 17 | 18 | // acc = accumulator 19 | // cur = current value 20 | 21 | 22 | //cc Mosh -------------------------------------------------------------------------------- /basic/11-intersection-of-two-sorted-array/intersection_of_two_sorted_arrays.test.js: -------------------------------------------------------------------------------- 1 | const intersection_of_two_sorted_arrays = require("./intersection-of-two-sorted-array"); 2 | 3 | const arr1 = [1, 2, 3, 4, 5, 6, 7, 7, 7, 8]; 4 | const arr2 = [2, 4, 5, 7, 8]; 5 | 6 | const intersection = [2, 4, 5, 7, 8]; 7 | 8 | describe("get the intersection of two sorted array", () => { 9 | it(`get the union of arr1: ${JSON.stringify(arr1)} and arr2:${JSON.stringify(arr2)}`, () => { 10 | expect(intersection_of_two_sorted_arrays(arr1,arr2)).toEqual(intersection); 11 | }) 12 | }) -------------------------------------------------------------------------------- /basic/09-count-max-number-of-ones/count_max_ones.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function count_max_ones(arr) { 4 | let count = 0; 5 | let max = 0; 6 | for (let i = 0; i < arr.length; ++i) { 7 | if (arr[i] === 1) { 8 | //increment count 9 | ++count; 10 | 11 | //max holds the max number of ones visited yet. 12 | max = Math.max(count, max); 13 | 14 | } else { 15 | //reset count to zero. 16 | count = 0; 17 | } 18 | 19 | } 20 | return max; 21 | } 22 | 23 | 24 | module.exports = count_max_ones; 25 | -------------------------------------------------------------------------------- /basic/09-count-max-number-of-ones/count_max_ones.test.js: -------------------------------------------------------------------------------- 1 | const count_max_ones = require("./count_max_ones"); 2 | 3 | const arr1 = [1, 1, 0, 0, 1, 1, 1]; 4 | const arr2 = [1, 1, 1, 1, 0, 0, 1, 1]; 5 | const arr3 = [1, 1, 1, 1, 1, 1, 0, 0, 1, 1]; 6 | const arr4 = [1, 1, 0, 0, 0, 1]; 7 | 8 | describe("count maximun ones in an array", () => { 9 | it("maximum numbero of ones should be 1", () => { 10 | expect(count_max_ones(arr1)).toBe(3); 11 | }) 12 | it("maximum number of ones should be 4", () => { 13 | expect(count_max_ones(arr2)).toBe(4); 14 | }) 15 | it("maximum number of ones should be 6", () => { 16 | expect(count_max_ones(arr3)).toBe(6); 17 | }) 18 | it("maximum number of ones should be 2", ()=>{ 19 | expect(count_max_ones(arr4)).toBe(2); 20 | }) 21 | }) -------------------------------------------------------------------------------- /basic/04-count-occurences/count-occurences.js: -------------------------------------------------------------------------------- 1 | // ? solution 1 2 | 3 | function countOccurrences(str, char) { 4 | let count = 0; 5 | 6 | for (let i = 0; i < str.length; i++) { 7 | if (str[i] === char) { 8 | count++; 9 | } 10 | } 11 | 12 | return count; 13 | } 14 | 15 | // const countOccurrences = (str, char) => { 16 | // return str.split(char).length - 1; 17 | // }; 18 | 19 | // insensitive case count 20 | 21 | // function countOccurrences(str, char) { 22 | // const lowerStr = str.toLowerCase(); 23 | // const lowerChar = char.toLowerCase(); 24 | // let count = 0; 25 | 26 | // for (let i = 0; i < lowerStr.length; i++) { 27 | // if (lowerStr[i] === lowerChar) { 28 | // count++; 29 | // } 30 | // return count; 31 | // } 32 | // } 33 | module.exports = countOccurrences; 34 | -------------------------------------------------------------------------------- /basic/07-move-zeros-to-end/move_zeros_to_end.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function move_zeros_to_end(arr) { 4 | //get the first zero in the array. 5 | let k = -1; 6 | let N = arr.length; 7 | let zero = 0; 8 | for (let i = 0; i < N; ++i) { 9 | if (arr[i] === zero) { 10 | k = i; 11 | //exit from the loop. 12 | break; 13 | } 14 | } 15 | for (let j = k + 1; j < N; ++j) { 16 | if (k === -1) return arr; 17 | //look for a non-zero number. 18 | if (arr[j] !== zero) { 19 | swap(arr, j, k); 20 | ++k; 21 | } 22 | } 23 | return arr; 24 | } 25 | 26 | function swap(arr, idx1, idx2) { 27 | const temp = arr[idx1]; 28 | arr[idx1] = arr[idx2]; 29 | arr[idx2] = temp; 30 | } 31 | 32 | module.exports = move_zeros_to_end; -------------------------------------------------------------------------------- /hackerank/simpleArraySum/readme.md: -------------------------------------------------------------------------------- 1 | Given an array of integers, find the sum of its elements. 2 | 3 | For example, if the array , , so return . 4 | 5 | Function Description 6 | 7 | Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer. 8 | 9 | simpleArraySum has the following parameter(s): 10 | 11 | ar: an array of integers 12 | Input Format 13 | 14 | The first line contains an integer, , denoting the size of the array. 15 | The second line contains space-separated integers representing the array's elements. 16 | 17 | Constraints 18 | 19 | Output Format 20 | 21 | Print the sum of the array's elements as a single integer. 22 | 23 | Sample Input 24 | 25 | 6 26 | 1 2 3 4 10 11 27 | Sample Output 28 | 29 | 31 30 | Explanation 31 | 32 | We print the sum of the array's elements: . 33 | 34 | 1 + 2 +3+ 4+ 10 + 11 =31 35 | -------------------------------------------------------------------------------- /basic/07-move-zeros-to-end/move_zeros_to_end.test.js: -------------------------------------------------------------------------------- 1 | const move_zeros_to_end = require("./move_zeros_to_end"); 2 | const arr1 = [1, 2, 0, 0, 3, 4, 5, 6, 7, 8, 0, 0, 15, 12, 13, 0, 3, 4]; 3 | const arr2 = [0, 0, 1, 2, 3]; 4 | const arr3 = [1, 3, 7, 9, 0, 0, 0] 5 | const arr4 = [11, 3, 44, 2, 5, 7] 6 | const test1 = [1, 3, 7, 9, 0, 0, 0]; 7 | const test2 = [1, 2, 3, 0, 0]; 8 | const test3 = [1, 2, 3, 4, 5, 6, 7, 8, 15, 12, 13, 3, 4, 0, 0, 0, 0, 0] 9 | describe("move zeros in a dataset to the end", () => { 10 | test("move zero(s) to the end", () => { 11 | expect(move_zeros_to_end(arr1)).toEqual(test3); 12 | expect(move_zeros_to_end(arr2)).toEqual(test2); 13 | expect(move_zeros_to_end(arr3)).toEqual(test1); 14 | }) 15 | test("return the intial array, since it contain no zero digit", () => { 16 | expect(move_zeros_to_end(arr4)).toEqual(arr4); 17 | }) 18 | }) -------------------------------------------------------------------------------- /basic/10-union-of-two-sorted-arrays/union_of_two_sorted_array.test.js: -------------------------------------------------------------------------------- 1 | const union_of_two_sorted_array = require("./union_of_two_sorted_array"); 2 | 3 | const arr1 = [1, 3, 5, 7, 9, 11]; 4 | const arr2 = [0, 2, 4, 6, 8, 10]; 5 | const arr3 = [13, 15, 17, 19, 21, 23, 27, 29]; 6 | const arr4 = [12, 14, 16, 18, 20, 25, 26, 30]; 7 | 8 | const union1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 9 | const union2 = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 27, 29, 30] 10 | describe("should get the union of two array", () => { 11 | it(`get the union of arr1: ${JSON.stringify(arr1)} and arr2: ${JSON.stringify(arr2)}`, () => { 12 | expect(union_of_two_sorted_array(arr1, arr2)).toEqual(union1); 13 | }) 14 | it(`get the union of arr1: ${JSON.stringify(arr2)} and arr2: ${JSON.stringify(arr2)}`, () => { 15 | expect(union_of_two_sorted_array(arr3, arr4)).toEqual(union2); 16 | }) 17 | }) -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # JS Challenges, Data Structures, and Algorithms.👩💻 2 | 3 | - Learn to solve problems with code, write efficient codes! 4 | 5 | # Questions🤔💭 6 | 7 | - Does the time taken for a code to run depend on the processor of the device used to code? 8 | 9 | # Setup🚀 10 | 11 | 1. Clone this repository to your local machine using `git clone`. 12 | 2. Navigate to the project directory: `cd panthreon`. 13 | 3. Install project dependencies using `npm install`. 14 | 4. Start the development server: `npm test`. 15 | 5. install [Code Runner](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) extension on your vscode. 16 | 17 | # Usage👩🏭 18 | Im pretty sure the files and folders are easy to naviagte and read, each codes are well documented and you have idea of what is really going on, feel free to ask questions too 19 | 20 | # Contribution 🛠 21 | Feel free to contribute to this repository, the little idea and correction is high appreciated, i promise your pull request will be accepted and merged. 22 | -------------------------------------------------------------------------------- /basic/07-move-zeros-to-end/README.md: -------------------------------------------------------------------------------- 1 | ## How does the move_zeros_to_end function work? 2 | ### Steps: 3 | 4 | - We look for the first zero(0) digit and save the index in a variable, say k, which we are going to use later. We initialize the variable to -1(reason for this will be mentioned in the below steps); 5 | 6 | - we check the rest of the dataset, in this case an array, we start the search at an index one greater (k + 1) than the index we found the first zero(0) digit, since we already know that index has a zero digit. 7 | 8 | - Before we start searching the rest of the dataset we check if our variable k is equal to -1. If yes, then it means the dataset does not contain a zero digit in the dataset. We therefore return from the function. 9 | 10 | - We search the rest of the dataset and perform a swap anytime we ecounter a non-zero digit and increment the variable k to hold the current index of the recently swapped zero digit. 11 | 12 | - After the search operation is done the dataset will have all the zero digit(s) moved to the end. 13 | -------------------------------------------------------------------------------- /random/map.js: -------------------------------------------------------------------------------- 1 | const numbers = [1, -1, 2, -2, 3, 4]; 2 | 3 | // filter only the positive numbers 4 | 5 | const filteredPositive = numbers.filter((num) => { 6 | return num >= 0; 7 | }); 8 | // console.log(filteredPositive) 9 | 10 | // here we are using the same results from the array we filtered and map through it to display a list item 11 | // NOTE filter and map method doesn't override the initial array 12 | const items = filteredPositive.map((item) => `