Wednesday, 3 May 2017

Cant return array outside function

I have a function

function gotData(data){
    result = data.val() 
    const urls = Object.keys(result)
                 .filter(key => result[key].last_res > 5)
                 .map(key => ({url: 's/price/' + result[key].url_site + '/'}))
}
console.log(urls)

But i cant console.log(urls) it show error as

ReferenceError: urls is not defined

How can I return urls?



via Moomoo Soso

No comments:

Post a Comment