Created
August 27, 2021 06:16
-
-
Save scriptjumper/f8f0f6eb11461f865493be18540a09cb to your computer and use it in GitHub Desktop.
Counting the ages that is greater or equal to 50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require("https"); | |
https.get("https://coderbyte.com/api/challenges/json/age-counting", (resp) => { | |
resp.setEncoding("utf-8"); | |
let data = ""; | |
// parse json data here... | |
resp.on("data", (d) => { | |
data += [d]; | |
}); | |
resp.on("end", () => { | |
let parsedData = data | |
.split(",") | |
.filter((data) => !data.indexOf(" age=")) | |
.map((data) => data.replace(" age=", "")) | |
.map((data) => parseInt(data)) | |
.filter((data) => { | |
return data >= 50; | |
}).length; | |
console.log(parsedData); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment