Skip to content

Instantly share code, notes, and snippets.

@oleggrishechkin
Last active June 7, 2021 19:21
Show Gist options
  • Save oleggrishechkin/47e8e2b2eafc297005af0b9ba3aea0e9 to your computer and use it in GitHub Desktop.
Save oleggrishechkin/47e8e2b2eafc297005af0b9ba3aea0e9 to your computer and use it in GitHub Desktop.

шаблон

// написать функцию, которая преобразует kebab-case в camelCase

const camelize = (string) => {
  // код
};

console.log(camelize('my-long-word')); // myLongWord
console.log(camelize('word')); // word

решение

const camelize = (string) => string
  .split('-')
  .map((word, index) => index === 0 ? word : word[0].toUpperCase() + word.slice(1))
  .join('');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment