Skip to content
dreamcode
dreamcode
Map
JS Array Transformer
Section challenge · IntermediateJavaScript
Reward: +50 XP
PROBLEM

JS Array Transformer

Write a function transformClouds(clouds, minHeight) that takes an array of cloud objects { name: string, height: number } and a number minHeight. It should:

  1. Filter out clouds with heights strictly less than minHeight.
  2. Map the remaining clouds to return an array of their name strings in uppercase.
  3. Return this array.

If no clouds match, return an empty array.

Examples
transformClouds([{ name: "cumulus", height: 3000 }, { name: "cirrus", height: 6000 }, { name: "stratus", height: 1500 }], 3000)
["CUMULUS", "CIRRUS"]
transformClouds([{ name: "fog", height: 200 }], 1000)
[]
solution.js
JAVASCRIPT
Saved as you type

Tests

0 of 3 passing
  • filter and uppercase
    transformClouds([{ name: "cumulus", height: 3000 }, { name: "cirrus", height: 6000 }, { name: "stratus", height: 1500 }], 3000)
    expected ["CUMULUS", "CIRRUS"]
  • all filtered out
    transformClouds([{ name: "fog", height: 200 }], 1000)
    expected []
  • empty array input
    transformClouds([], 500)
    expected []
On the line
+50 XP
Pass all 3 tests to claim it.