My code was 2nd. I needed it as short as possible

  javascript, string

The goal was to create a phone number from a given string(S), which was random. the format of the number had to be (XXX) XXX-XXXX. Can the code be made even shorter?

S=readline()
        let X="("+S[0]+S[1]+S[2]+")"+
        " "+S[3]+S[4]+S[5]+"-"+S[6]+S[7]+S[8]+S[9]
    print(X)

Source: Ask Javascript Questions

LEAVE A COMMENT