[Vuejs]-How do I segment this array according to returned key in Vue JavaScript?

0👍

I assume the process is the task object { "id": 1, "project_id": 6, "action_1": 0, "action_2": 0, "action_3": 0, ..."action_132": 0

Object.keys(process).map(key => {
    if (key.includes('action')) {
        const actionNumber = key.substring(7)     // get action number
        if (1 <= actionNumber <= 3) {
             task1.push(process[key])             // push the value of that action to task
        }
        ... for another eondition
    }

})

Leave a comment