What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-18 07:30:11
reverse keys and values in object javascript
//The concise way by using ES6 syntax like this. const obj = {A : 1, B : 2, C : 3, D : 4} function objectFlip(obj) { return Object.entries(obj).reduce((acc, [key, value]) => (acc[value] = key, acc), {}) } console.log('input: ',obj); console.lo... Add solution -
Python 2021-10-29 08:40:40
what is tf.data.dataset.reduce()
# import tensorflow import tensorflow as tf # using tf.data.Dataset.reduce() method data = tf.data.Dataset.from_tensor_slices([1, 2, 3, 4, 5]) print(data.reduce(0, lambda x, y: x + y).numpy()) # it return the summation of all element # 0 + (1+2+... Add solution -
Javascript 2021-10-10 04:33:13
reverse key and value in object js
//The concise way by using ES6 syntax like this. const obj = {A : 1, B : 2, C : 3, D : 4} function objectFlip(obj) { return Object.entries(obj).reduce((acc, [key, value]) => (acc[value] = key, acc), {}) } console.log('input: ',obj); console.lo... Add solution -
Javascript 2021-09-27 16:44:02
flatten nested array javascript
// using recursion, .reduce() and .concat() methods // works with arrays of any depth function flatten(arr) { return arr.reduce((acc, cur) => acc.concat(Array.isArray(cur) ? flatten(cur) : cur), []); }; const arr = [[1,2],[3,[4,[5]]]]; const flatte... Add solution -
Other 2021-09-21 11:05:02
get flatten array from nested array
// using recursion, .reduce() and .concat() methods // works with arrays of any depth function flatten(arr) { return arr.reduce((acc, cur) => acc.concat(Array.isArray(cur) ? flatten(cur) : cur), []); }; const arr = [[1,2],[3,[4,[5]]]]; const flatte... Add solution
Best helpers
Insane
+5
OlegSerov
+5
Paola Garcia
+5
SweetSweet
+5
Amauri
+5
Omar Kooheji
+5
Leshui
+5
JoshuaFicy
+5
TheLimper
+5
Kenneth Duda
+5