Answer to Question #177718 in HTML/JavaScript Web Application for adhi chinna

Question #177718

Array of String to UpperCase

myArray of strings as an input, write a JS program to convert all the strings in myArray to uppercase.Input

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing an array of strings in uppercase

Sample Input 1

[ 'book', 'table', 'strawberries', 'lemons' ]

Sample Output 1

[ 'BOOK', 'TABLE', 'STRAWBERRIES', 'LEMONS' ]

Sample Input 2

[ 'my best friend', 'florida', 'winter' ]

Sample Output 2

[ 'MY BEST FRIEND', 'FLORIDA', 'WINTER' ]


"use strict";


process.stdin.resume();

process.stdin.setEncoding("utf-8");

let inputString = "";

let currentLine = 0;

process.stdin.on("data", (inputStdin) => {

 inputString += inputStdin;

});

process.stdin.on("end", (_) => {

 inputString = inputString.trim().split("\n").map((str) => str.trim());

 main();

});

function readLine() {

 return inputString[currentLine++];

}

/* not modify anything above this line */


1
Expert's answer
2021-04-02T07:09:32-0400
"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((str) => str.trim());
    main();
});

function readLine() {
    return inputString[currentLine++];
}
/* not modify anything above this line */

function arrayToUpperCase(arr) {
    return arr.map( item => item.toUpperCase() )
}

function main() {
    console.log( arrayToUpperCase([ 'book', 'table', 'strawberries', 'lemons' ]) );
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS