Refactor the code to use composition.

/*
  Create an `ids` array from a `products` array.
  The new array should contain only the ids of products with prices below 1000,
  ordered by the price from the cheapest to the most expensive.
*/
let products = [
  {id: 1, price: 500},
  {id: 2, price: 1500},
  {id: 3, price: 750},
  {id: 4, price: 1750},
  {id: 5, price: 150},
  {id: 6, price: 750},
]

let cheapProducts = R.filter(p => p.price < 1000, products)
let cheapSortedProducts = R.sortBy(R.prop("price"), cheapProducts)
let ids = R.pluck("id", cheapSortedProducts)

console.log(ids)

Download the sources and solve the task on your own machine.