What do you want to save?
Add Code snippet
New code examples
-
Other 2022-03-19 13:10:05
javascript loop an array
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution -
Javascript 2022-03-17 01:45:19
for array javascript
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution -
Other 2021-11-09 11:56:09
Iterating or loop through the elements of an array is with a for loop (for):
var keys = Object.keys(o); // Get an array of property names for object o var values = [] // Store matching property values in this array for(var i = 0; i < keys.length; i++) { // For each index in the array var key = keys[i]; ... Add solution -
R 2021-10-24 06:09:08
R convert list of lists into single numeric list
# Set seed so results able to be replicated: set.seed(123) # Make arbitrary List of sub-lists in each index: list.of.lists <- list() for (i in 1:3) { list.of.lists[[i]] <- rnorm(5) } # Print list.of.lists list.of.lists #[[1]] #[1] -0.560475... Add solution -
Python 2021-10-23 17:49:12
how to convert adjacency list to adjacency matrix
#Python: def convert_to_matrix(graph): matrix = [] for i in range(len(graph)): matrix.append([0]*len(graph)) for j in graph[i]: matrix[i][j] = 1 return matrix #the lst shows in a form of each index(each inner list)... Add solution -
Javascript 2021-10-23 16:52:08
putting a loop into an array javascript
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution -
Javascript 2021-10-20 21:48:05
iterate array javascript
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution -
Other 2021-10-10 14:29:04
Find index of 0 to be replaced to get maximum length sequence of continuous ones
def findIndexofZero(A): max_count = 0 # stores maximum number of 1's (including 0) max_index = -1 # stores index of 0 to be replaced prev_zero_index = -1 # stores index of previous zero count = 0 # ... Add solution -
Javascript 2021-10-01 04:20:04
traverse an array in javascript
let array = ['Item 1', 'Item 2', 'Item 3']; // Here's 4 different ways for (let index = 0; index < array.length; index++) { console.log(array[index]); } for (let index in array) { console.log(array[index]); } for (let value of array) { console... Add solution