Day 13 : Postman Challenge - Script to count the species having avg height > 100

Can someone please help me with the script to count the number of species whose average height is greater than 100 from the response body of this request https://swapi.dev/api/species

This is how the response look for single species and continue further
{
“count”: 37,
“next”: “https://swapi.dev/api/species/?page=2”,
“previous”: null,
“results”: [
{
“name”: “Human”,
“classification”: “mammal”,
“designation”: “sentient”,
“average_height”: “180”,
“skin_colors”: “caucasian, black, asian, hispanic”,
“hair_colors”: “blonde, brown, black, red”,
“eye_colors”: “brown, blue, green, hazel, grey, amber”,
“average_lifespan”: “120”,
“homeworld”: “https://swapi.dev/api/planets/9/”,
“language”: “Galactic Basic”,
“people”: [
https://swapi.dev/api/people/66/”,
https://swapi.dev/api/people/67/”,
https://swapi.dev/api/people/68/”,
https://swapi.dev/api/people/74/
],
“films”: [
https://swapi.dev/api/films/1/”,
https://swapi.dev/api/films/2/”,
https://swapi.dev/api/films/3/”,
https://swapi.dev/api/films/4/”,
https://swapi.dev/api/films/5/”,
https://swapi.dev/api/films/6/
],
“created”: “2014-12-10T13:52:11.567000Z”,
“edited”: “2014-12-20T21:36:42.136000Z”,
“url”: “https://swapi.dev/api/species/1/
},

@sabbyk Welcome to the community :partying_face:

I can give some hints here:

  1. If you are new to JS, try traditional for loop to looping through the entire response, and you need to add a conditional statement inside to check the “average_height>100”
  2. Create an array and push the count if the it satisfies the conditional statement above.

Please try and share the scripts, then we will try to help debug it :blush:

Thank you so much @bpricilla for your help. I did complete that challenge using your hints.

1 Like