I want to get another array from the original array:
input example:
[[18, 20],[45, 2],[61, 12],[37, 6],[21, 21],[78, 9]] The conclusion should be the following: the first number - the age should be more than 55 , and the second - the work experience should be more than 7 .
["Open", "Open", "Senior", "Open", "Open", "Senior"] My code seems to solve, but I am ready to throw it into the furnace, the solution is not universal, I ask for help:
var arr = [[18, 20],[45, 2],[61, 12],[37, 6],[21, 21],[78, 9]]; var arr2 = []; function openOrSenior(data){ if (Array.isArray(data)) { for (var i = 0; i < data.length; i++) { if (data[i][0] > 55 && data[i][1] > 7) { arr2.push("Senior"); } else { arr2.push("Open"); } } return arr2; } } console.log(openOrSenior(arr)); - How to get rid of global variables?
- How to check on an array universally?