Skip to content

114 - CamelCase #25014

Open
Open

Description

@studymachiney
// your answers
type IsAlphabet<T extends string> = Lowercase<T> extends Uppercase<T>
    ? false
    : true

type CamelCase<
    S extends string,
    Result extends string = ''
> = S extends `${infer Left}${infer Rest}`
    ? IsAlphabet<Left> extends true
      ? Result extends `${infer Prefix}_`
        ? CamelCase<Rest,`${Prefix}${Uppercase<Left>}`>
        : CamelCase<Rest, `${Result}${Lowercase<Left>}`>
      : CamelCase<Rest, `${Result}${Left}`>
    : Result

Activity

  1. added
    answer
    en
    on Mar 14, 2023
  2. HubooDeclan commented on Apr 28, 2023

    @HubooDeclan

    Great work! Love the alphabet check

  3. GolubevS commented on Dec 25, 2025

    @GolubevS

    Tail-recursive solution, great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    114answeren

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions