What do you want to save?
Add Code snippet
New code examples
-
Other 2022-03-27 18:30:09
validar si un numero es par javascript map
// Return a new array where even numbers are multiplied by 2 let arr = [1, 2, 3, 4, 5, 6, 7] function consoleEven(arr) { let data = arr.map((num) => (num % 2 === 0 ? num * 2 : num * 1)) console.log(data) // [1, 4, 3, 8, 5, 12, 7] } // ? is... Add solution -
Javascript 2022-03-21 22:15:23
Slice Example
/"slice() copies or extracts a given number of elements to a new array"/ let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear']; let todaysWeather = weatherConditions.slice(1, 3); // todaysWeather equals ['snow', 'sleet']; // weath... Add solution -
Javascript 2022-02-12 05:25:18
how to update specific key of an object in reducer
case COMPLETE_TODO: { const index = state.todos.findIndex(todo => todo.id === action.payload); //finding index of the item const newArray = [...state.todos]; //making a new array newArray[index].completed = true//changing value in the new array... Add solution -
Other 2021-11-21 16:00:29
ruby select
# A new array containing all elements of array for which the given block returns a true value. # Ruby code for select() method # declaring array a = [18, 22, 33, 3, 5, 6] # select puts "select method : #{a.select {|num| num > 10 }}\n\n" #... Add solution -
Ruby 2021-11-16 12:41:18
ruby reorder keys in hash
# First thing to note that #sort/#sort_by will return a new array. Therefore, if we want to return the sorted hash in hash format, we need to call #to_h after #sort. hash = { a:1, bb:2, ccc:4, dddd:3, eeeee:2} # sort on key in decending order puts hash.... Add solution -
Other 2021-10-21 19:42:18
[].slice.call(
/"slice() copies or extracts a given number of elements to a new array"/ let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear']; let todaysWeather = weatherConditions.slice(1, 3); // todaysWeather equals ['snow', 'sleet']; // weath... Add solution
Best helpers
Ranking is empty