I have array like this structure
["12 18:00", "15 17:30","16 12:00", "12 21:30", "9 10:30"...]
and it has unknown number of elements. I want get every hour:minute for selected element. Example: if ele=="12" then get 18:00, 21:30. Maybe array has more "12 16:30","12 13:00" etc elements. Then also get 16:30, 13:00. All get elements 18:00, 21:30, 16:30, 13:00
Help me for this solution.
You can do this:
const array = ["12 18:00", "15 17:30","16 12:00", "12 21:30", "9 10:30"];
const getItems = number => {
return array.filter(item => item.split(" ")[0] === number.toString()).map(item => item.split(" ")[1])
}
console.log(getItems(12));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.