What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-19 01:45:07
google app script column to array indexOf
// Google app script column to array indexOf var numRows = sheet.getLastRow(); var nameRng = sheet.getRange(2, 3, numRows).getValues(); // this is [[v1],[v2],... var nameArr = String(nameRng).split(","); // force column range into a String() ... Add solution -
Other 2021-11-20 13:03:22
commonCharacterCount
// Given two strings, find the number of common characters between them. // Example // For s1 = "aabcc" and s2 = "adcaa", the output should be // commonCharacterCount(s1, s2) = 3. // Strings have 3 common characters - 2 "a"... Add solution -
Javascript 2021-11-16 13:47:18
find second largest number in array javascript
var secondMax = function (){ var arr = [20, 120, 111, 215, 54, 78]; // use int arrays var max = Math.max.apply(null, arr); // get the max of the array arr.splice(arr.indexOf(max), 1); // remove max from the array return Math.max.apply(nul... Add solution -
Javascript 2021-10-19 01:32:09
javascript find the second highest Element from array
var secondMax = function (arr){ var max = Math.max.apply(null, arr), // get the max of the array maxi = arr.indexOf(max); arr[maxi] = -Infinity; // replace max in the array with -infinity var secondMax = Math.max.apply(null, arr); // ... Add solution -
Javascript 2021-09-23 09:40:03
linear search javascript
// arr.indexOf(val) function linearSearchIndexOf(arr, val) { for (let i = 0; i < arr.length; i++) { if (arr[i] === val) { return i; } } return -1; } // arr.includes(val) function linearSearchIncludes(arr, val) { for (let i = 0;... Add solution -
Javascript 2021-08-28 04:29:02
javascript compare duplicates in array
let strArray = [ "q", "w", "w", "w", "e", "i", "u", "r"]; let findDuplicates = arr => arr.filter((item, index) => arr.indexOf(item) != index) console.log(findDuplicates... Add solution