Skip to content

Instantly share code, notes, and snippets.

@scriptjumper
Created August 27, 2021 06:16
Show Gist options
  • Save scriptjumper/f8f0f6eb11461f865493be18540a09cb to your computer and use it in GitHub Desktop.
Save scriptjumper/f8f0f6eb11461f865493be18540a09cb to your computer and use it in GitHub Desktop.
Counting the ages that is greater or equal to 50
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