What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-16 23:45:12
permutaciones con repeticion javascript
function permutator (input) { var set =[]; function permute (arr, data) { var cur, memo = data || []; for (var i = 0; i < arr.length; i++) { cur = arr.splice(i, 1)[0]; if (arr.length === 0) set.push(memo.concat([cur])); ... Add solution -
Javascript 2022-03-11 08:10:23
javascript splice
let arr = ['foo', 'bar', 10, 'qux']; // arr.splice(<index>, <steps>, [elements ...]); arr.splice(1, 1); // Removes 1 item at index 1 // => ['foo', 10, 'qux'] arr.splice(2, 1, 'tmp'); // Replaces 1 item at index 2 with 'tmp' // => ['... Add solution -
Javascript 2022-02-15 13:25:12
8.3.1. Common Array Methods // splice Examples (.splice)
//The general syntax for this method is: arrayName.splice(index, number of elements to change, item1, item2, ...); //Inside the parentheses (), only the first argument is required. /*The splice method modifies one or more elements anywhere in the array.... Add solution -
Javascript 2022-01-26 03:05:21
what is splice in javascript
let arr = ['foo', 'bar', 10, 'qux']; // arr.splice(<index>, <steps>, [elements ...]); arr.splice(1, 1); // Removes 1 item at index 1 // => ['foo', 10, 'qux'] arr.splice(2, 1, 'tmp'); // Replaces 1 item at index 2 with 'tmp' // => ['... Add solution -
Javascript 2021-11-20 16:20:09
add object in array javascript to index using lodash
var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; console.log(arr.join()); arr.splice(2, 0, "Lene"); console.log(arr.join()); 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-11-15 08:35:22
splice method js
let arr = ['foo', 'bar', 10, 'qux']; // arr.splice(<index>, <steps>, [elements ...]); arr.splice(1, 1); // Removes 1 item at index 1 // => ['foo', 10, 'qux'] arr.splice(2, 1, 'tmp'); // Replaces 1 item at index 2 with 'tmp' // => ['... Add solution -
Javascript 2021-11-12 19:24:31
javascript array push element at index
var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; console.log(arr.join()); // Jani,Hege,Stale,Kai Jim,Borge arr.splice(2, 0, "Lene"); consol... Add solution