F
F
fronter-up2017-10-24 18:29:21
css
fronter-up, 2017-10-24 18:29:21

Validating js object values, how to write better?

Good afternoon! Please tell me how to write better.
From the code, you can understand what it should do.
You need to check the value of the objects in the array and if they match, write the value to the variable.
At the moment it works, but somehow not correctly.

list.map((item, i, arr) => {
              let park;
              if(typeof arr[i + 1] !== 'undefined') {
                if(arr[i].ln === arr[i + 1].ln) {
                  park= true;
                } else{
                  park= false;
                }
              }
})

Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Udaltsov, 2019-07-26
@uashkki

I'm not sure that I helped you, because I didn't really understand the essence of the task, but:
https://codepen.io/anon/pen/jgMeKg

A
Aleksandr, 2019-07-26
@Sashjkeee

Either this
Either use flexbox as shown by Kirill Udaltsov
Or use css-grid

F
fiskus, 2017-11-02
@fiskus

From the code you can understand what it should do

You can't, it doesn't work for you the way you want.
And what result do you want to get?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question