Js array traversing objects

clipboard.png

I want to take the url in the object status = = "success" instead of the url of the object status = = "ready". It can"t be realized by using array forEach and filter.

May.07,2022

the phone really can't type the code literal description. Use filter

.

return item.status===sucess
and item.url

just OK


const result = arr.reduce(
  (total, cur) => (cur.status === 'success' ? [...total, cur.url] : [...total]),
  []
)

let urls = arr.filter (item= > item.status=== "success") .map (item= > item.url)


const arr = [{status:'success',url:'/a'},{status:'success',url:'/b'},{status:'ready',url:'/c'}];
const arr1 = arr.filter(v=>v.status!=='ready'); // [{status:'success',url:'/a'},{status:'success',url:'/b'}]
const arr2 = arr1.map(v=>v.url); // ['/a','/b']
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45256-4383b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45256-4383b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?