Can I force cheerio to return an array?

I’m using cheerio and axios to do some web scraping. Right now, I’m trying to select $(".color-data"), which should return three elements. However, it outputs a large, messy object, and if I use .toArray(), I get an error.

Any ideas on what to do? Here’s my code:

//import our packages
const axios = require("axios")
const cheerio = require("cheerio")
const data = []

//load html-color-names
    .then(html => {
    const $ = cheerio.load(
    var arr = $(".color-data")
    console.log(arr) //returns object, arr.toArray() is a no go, arr.text() returns string

Update: I’ve tried - they suggest using each and pushing it to an array, but it doesn’t work. Any other ideas?

Update 2: If i use .text(), I get:



            rgb(153, 50, 204)

There’s too much whitespace to efficiently split this. I tried .html(), and I just get


.data() returns an empty object {}.
More whitespace, again. Any ideas?

I solved it!

arr.each(function(i, elem) {
  a[i] = $(this).text();

Turns out, arrow expressions don’t work in Cheerio, I don’t know why.