This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeDuplicates = (sortedArray) => { | |
const filteredArray = []; | |
sortedArray.forEach((num)=> { | |
if(!filteredArray.includes(num)) { | |
filteredArray.push(num); | |
} | |
}); | |
return filteredArray.length; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeInstance = (nums, val) => { | |
if(!Array.isArray(nums) || nums.length === 0) return 0; | |
if(!val) return nums.length; | |
let newArrayLength = 0; | |
for(let i = 0; i < nums.length; i++) { | |
if(nums[i] !== val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const startAndStopPosition = (nums, val) => { | |
if(!Array.isArray(nums) || nums.length === 0) return [-1, -1]; | |
// Initialization of Variables | |
let initialIndex = 0; | |
let count = 0; | |
let startAndStop = []; | |
// Looping through the array; | |
for(let i = 0; i < nums.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const productFunction = (nums) => { | |
let zeroCount = 0; | |
let temporalProduct = 1; | |
if(!Array.isArray(nums) || nums.length === 0) return []; | |
if(nums.length === 1) return [0]; | |
const totalProduct = nums.reduce((product, num) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortFunction = (firstArray, secondArray) => { | |
if ( | |
(!Array.isArray(firstArray) || firstArray.length === 0) && | |
(!Array.isArray(secondArray) || secondArray.length === 0) | |
) { | |
return []; | |
} | |
if (!Array.isArray(firstArray) || firstArray.length === 0) { | |
return secondArray; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shuffleClass = (arr, num) => { | |
if (!Array.isArray(arr) || arr.length === 0) return []; | |
if (typeof num !== "number") { | |
return arr; | |
} | |
if (num === 0) { | |
return arr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const twoSum = (array, sum) => { | |
if (!Array.isArray(array) || array.length === 0) return [0, 0]; | |
if (typeof sum !== "number") return [0, 0]; | |
const secondValues = {}; | |
for (let i = 0; i < array.length; i++) { | |
let secondValue = sum - array[i]; | |
if (secondValues[array[i]]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const evenAndOdd = (array) => { | |
if (!Array.isArray(array) || array.length === 0) return [0, 0]; | |
let evenSum = 0; | |
let oddSum = 0; | |
for(let i = 0; i < array.length; i++){ | |
if(array[i] % 2 === 0) { | |
evenSum = evenSum + array[i]; | |
} | |
else { | |
oddSum = oddSum + array[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reverseVowels = (word) => { | |
if (typeof word !== 'string') return "Invalid Input Parameter"; | |
let start = 0; | |
let end = word.length - 1; | |
let vowels = { | |
a: true, | |
e: true, | |
i: true, | |
o: true, | |
u: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "psbt", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"keywords": [], | |
"author": "", |
OlderNewer