0

Is there a way to compare the current value with previous value using a for each loop?

I'm able to do it using a for loop but I want to us a for each loop because I don't know the index length of the elements I'm looping. When I use a for loop, I use the i to refer to the elements of my array. Like: Current item: myArray[i] Next item: myArray[i+1] Previous item: myArray[i-1] I know we have clever brains here so someone would know the answer

22nd Sep 2017, 8:28 AM
Sibusiso Mbambo
12 Antworten
+ 1
thanks for your input, I'm learning new stuff everyday
22nd Sep 2017, 9:45 AM
Sibusiso Mbambo
+ 1
I inserted commas on each iteration, I hope I did right. https://code.sololearn.com/cC4sYmFxAIQ3/?ref=app
22nd Sep 2017, 10:40 AM
Sibusiso Mbambo
0
how gordie? Is there a source code for that?
22nd Sep 2017, 8:46 AM
Sibusiso Mbambo
0
thanks
22nd Sep 2017, 9:00 AM
Sibusiso Mbambo
0
ok, Is it possible to add a comma from each iteration on a for each loop gordie?
22nd Sep 2017, 9:11 AM
Sibusiso Mbambo
0
ok
22nd Sep 2017, 9:14 AM
Sibusiso Mbambo
0
how
22nd Sep 2017, 9:36 AM
Sibusiso Mbambo
0
how
22nd Sep 2017, 9:36 AM
Sibusiso Mbambo
0
How can I split the teams and be able to select them individually by using their index on the on the array? Example: Manchester United Arsenal Orlando Pirates Manchester City... Please see the below code! https://code.sololearn.com/cC4sYmFxAIQ3/?ref=app
22nd Sep 2017, 3:12 PM
Sibusiso Mbambo
0
I'm getting an error when I run the code.
22nd Sep 2017, 3:13 PM
Sibusiso Mbambo
22nd Sep 2017, 3:28 PM
Sibusiso Mbambo
0
just posted!
22nd Sep 2017, 3:33 PM
Sibusiso Mbambo