What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-17 10:00:12
Math max with array js
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max ... Add solution -
Javascript 2022-03-16 22:30:12
javascript loop through arrya
var data = [1, 2, 3, 4, 5, 6]; // traditional for loop for(let i=0; i<=data.length; i++) { console.log(data[i]) // 1 2 3 4 5 6 } // using for...of for(let i of data) { console.log(i) // 1 2 3 4 5 6 } // using for...in for(let i in data) { con... Add solution -
C++ 2022-03-15 06:55:06
segment tree complexity
// C++ program to show segment tree operations like construction, query // and update #include <bits/stdc++.h> using namespace std; // A utility function to get the middle index from corner indexes. int getMid(int s, int e) { return s + (e -s)... Add solution -
Javascript 2022-02-26 18:35:07
js max array
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max ... Add solution -
Javascript 2022-02-24 15:50:02
maximum element in an array javascript
// For large data, it's better to use reduce. Supose arr has a large data in this case: const arr = [1, 5, 3, 5, 2]; const max = arr.reduce((a, b) => { return Math.max(a, b) }); // For arrays with relatively few elements you can use apply: const max ... Add solution -
Javascript 2022-02-16 18:35:08
loop through an array in js
var data = [1, 2, 3, 4, 5, 6]; // traditional for loop for(let i=0; i<=data.length; i++) { console.log(data[i]) // 1 2 3 4 5 6 } // using for...of for(let i of data) { console.log(i) // 1 2 3 4 5 6 } // using for...in for(let i in data) { con... Add solution -
C++ 2022-02-12 03:45:02
how to search integer in c++
//******************************************************** // search algorithm for arrays //******************************************************** #include <iostream> using namespace std; void initializeArray(int list[], int listSize); int ... Add solution -
Other 2022-01-29 21:00:16
MPI_STATUS_IGNORE
MPI_STATUS_IGNORE informs MPI to not fill an MPI_Status, which saves some time. It is used in message reception (MPI_Recv), non-blocking operations wait (MPI_Wait, MPI_Waitany) and test (MPI_Test, MPI_Testany). A version of MPI_STATUS_IGNORE exists als... Add solution -
Javascript 2022-01-27 19:50:26
ellipsis javascript
function sum(x, y, z) { return x + y + z; } const numbers = [1, 2, 3]; console.log(sum(...numbers)); // expected output: 6 console.log(sum.apply(null, numbers)); // expected output: 6 /* Spread syntax (...) allows an iterable such as an array expres... Add solution -
Javascript 2021-11-21 01:19:22
spread operator in javascript
// spread operators can be used for arrays or objects // cloning to prevent mutation. let numList = [1,2,3]; let numListClone = [...numList]; // [1, 2, 3] // spread operator for destructuring. let animal = { name: 'dog', color: 'brown', age: 7 }; ... Add solution
Best helpers
Jean Luis
+5
Terry3497
+5
Aown Ali
+5
Ishan Yadav
+5
SunnyHills
+5
Rocky DeHart
+5
Numeri
+5
Martinako
+5
Eve noonan
+5
Cynthia
+5