Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.1 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b7687dded630607aceccb3 Challenge 49: CSV Header Parser 28 challenge-49

--description--

Given the first line of a comma-separated values (CSV) file, return an array containing the headings.

  • The first line of a CSV file contains headings separated by commas.
  • Remove any leading or trailing whitespace from each heading.

--hints--

getHeadings("name,age,city") should return ["name", "age", "city"].

assert.deepEqual(getHeadings("name,age,city"), ["name", "age", "city"]);

getHeadings("first name,last name,phone") should return ["first name", "last name", "phone"].

assert.deepEqual(getHeadings("first name,last name,phone"), ["first name", "last name", "phone"]);

getHeadings("username , email , signup date ") should return ["username", "email", "signup date"].

assert.deepEqual(getHeadings("username , email , signup date "), ["username", "email", "signup date"]);

--seed--

--seed-contents--

function getHeadings(csv) {

  return csv;
}

--solutions--

function getHeadings(csv) {
  return csv
    .split(",")
    .map(h => h.trim());
}