Zalando Interview Question: Convert all the words with 3 ... | Glassdoor.co.in

Interview Question

Front-End Developer Interview Berlin (Germany)

Convert all the words with 3 alphabets to upper case in a

  sentence.(JS)
Answer

Interview Answer

3 Answers

0

function convert(string){
return string.split(' ').map(function(value){
       if(value.length == 3)
            return value.toUpperCase();
       return value;

}).join(' ');
}

Himanshu Mittal on 09-Aug-2016
0

better way is:
 function convertStr(str, limit){
                if(limit === 0){return new Error("required limit is minimum 1")};
               var temp = str.split('');
                   for(var i=0; i

sajankumar vijayan on 19-Dec-2016
0

sentences = "ben seni severim cocuk"
sentences.split(" ").map(word => convert(word))

function convert(word){
    if(word.length === 3) {
        word = word.toUpperCase();
        return word
    }
    return word
}

Nur on 22-Feb-2019

Add Answers or Comments

To comment on this, Sign In or Sign Up.