Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterate over a list of values using javascript

Tags:

javascript

I am looking to iterate over a list of values using javascript.

I have a list like this

Label: A    Value:  Test    Count: 4
Label: B    Value:  Test2   Count: 2
Label: C    Value:  Test3   Count: 4
Label: D    Value:  Test4   Count: 1
Label: C    Value:  Test5   Count: 1

My goal is to pass each row into different functions based on the label. I am trying to figure out if a multidimensional array is the best way to go.

like image 623
user990951 Avatar asked Feb 08 '13 16:02

user990951


1 Answers

well it's been 8 years but today you can use for ... of

const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}

source : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of

like image 73
clement box Avatar answered Sep 28 '22 03:09

clement box