What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-26 01:46:27
javascript split array into chunks of
function splitArrayIntoChunksOfLen(arr, len) { var chunks = [], i = 0, n = arr.length; while (i < n) { chunks.push(arr.slice(i, i += len)); } return chunks; } var alphabet=['a','b','c','d','e','f']; var alphabetPairs=splitArrayIntoC... Add solution -
Javascript 2022-01-23 00:20:50
return first letter of string javascript in uppercase
//capitalize only the first letter of the string. function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } //capitalize all words of a string. function capitalizeWords(string) { return string.repl... Add solution -
Javascript 2022-01-22 17:41:29
es6 reverse foreach
var arr = [1, 2, 3, 4, 5]; arr.slice().reverse() .forEach(function(item) { console.log(item);  ... Add solution -
Javascript 2022-01-22 09:45:12
array index javascript show only first 2 elements
array.slice(0, n); Add solution -
Javascript 2021-12-23 16:08:11
javascript how to get every element after the 1st in an array
var arguments = ['One', 'Two', 'Three']; var middle = arguments.slice(1, -1); // will take away the 1st from the start and the 1st from the end console.log(middle); // once logged it will only show 'Two' Add solution -
Javascript 2021-11-21 14:40:31
code to convert rgb to hsl color
// see: https://en.wikipedia.org/wiki/RGB_color_model // see: https://en.wikipedia.org/wiki/HSL_and_HSV // expects R, G, B, Cmax and chroma to be in number interval [0, 1] // returns undefined if chroma is 0, or a number interval [0, 360] degrees functio... Add solution -
Javascript 2021-11-21 04:50:12
implement a merge sort algorithm JS
// Merge Sort Implentation (Recursive) function mergeSort (unsortedArray) { if (unsortedArray.length <= 1) { return unsortedArray; } const middle = Math.floor(unsortedArray.length / 2); const left = unsortedArray.slice(0, middle); co... Add solution
Best helpers
Bread
+5
Annu_tiger
+5
Webelo
+5
Des Wilson
+5
Twbrown
+5
Dreeves
+5
Xoxocrow
+5
Arash.amd
+5
Gaussler
+5
Kenny W
+5
Chris Crook
+5
Xzhu
+5
Steven Choi
+5
AndrewBC
+5
Static
+5
C. Starr
+5