Apr 03, 2017

I don't quite know how to encapsulate this Arcade level, I suppose you could say it deals with string treatment. Want to codefight?

Enclosed in Brackets (300/300)

Given a string, enclose it in round brackets.


function encloseInBrackets(inputString) {
    return '('+inputString+')';

Proper Noun Correction (300/300)

Proper nouns always begin with a capital letter, followed by small letters.

Correct a given proper noun so that it fits this statement.


function properNounCorrection(noun) {
    var lowercase = noun.substr(1).toLowerCase();
    return noun[0].toUpperCase() + lowercase;

Is Tandem Repeat? (300/300)

Determine whether the given string can be obtained by one concatenation of some string to itself.


function isTandemRepeat(inputString) {
    if(inputString.length % 2 != 0)
        return false; 
    var word_limit = inputString.length / 2;
    return  inputString.substr(0, word_limit) == inputString.substr(word_limit);

Is Case-Insensitive Palindrome? (300/300)

Given a string, check if it can become a palindrome through a case change of some (possibly, none) letters.


function isCaseInsensitivePalindrome(inputString) {
    var lc = inputString.toLowerCase(),
        even = lc.length % 2 == 0;
    var mid_point = even ?
                    (lc.length/2) - 1 :
    var reversed = even ?
                   lc.substr(mid_point+1).split('').reverse().join('') :

    return lc.substr(0,mid_point+1) == reversed;

Find Email Domain (300/300)

Given a valid email address, find its domain part.


function findEmailDomain(address) {
    var at_symb = address.lastIndexOf('@');
    return address.substr(at_symb+1);

HTML End Tag By Start Tag (300/300)

Given the starting HTML tag, find the appropriate end tag which your editor should propose.


function htmlEndTagByStartTag(startTag) {
    // Determine tag without <>
    var space = startTag.indexOf(' '),
        tag = space > -1 ? startTag.substr(1, space-1) : startTag.substr(1,startTag.length-2);
    return '</' + tag + '>';

Is MAC48 Address? (300/300)

Your task is to check by given string inputString whether it corresponds to MAC-48 address or not.


function isMAC48Address(inputString) {
    var regex = new RegExp('([A-F0-9]{2}-){5}[A-F0-9]{2}$', 'g');
    return regex.exec(inputString) != null;

Is Unstable Pair? (300/300)

Some file managers sort filenames taking into account case of the letters, others compare strings as if all of the letters are of the same case. That may lead to different ways of filename ordering.

Call two filenames an unstable pair if their ordering depends on the case.

To compare two filenames a and b, find the first position i at which a[i] ≠ b[i]. If a[i] < b[i], then a < b. Otherwise a > b. If such position doesn't exist, the shorter string goes first.

Given two filenames, check whether they form an unstable pair.


function isUnstablePair(filename1, filename2) {
     var filename1_lessthan_2 = filename1.toLowerCase() < filename2;
     return (filename1.toUpperCase() <= filename2) != filename1_lessthan_2;