Array of strings to uppercase in javascript assignment expert
Array of Strings to UpperCase Show Given an array myArray of strings as an input, write a JS program to convert all the strings in myArray to uppercase.Input
Output
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' ] Array of String to 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 */ View Discussion Improve Article Save Article View Discussion Improve Article Save Article Below is the example of the String toUpperCase() Method.
JavaScript
GEEKSFORGEEKS str.toUpperCase() method converts the entire string to Upper case. This method does not affect any of the special characters, digits, and the alphabets that are already in the upper case. str.toUpperCase() Return value: var str = 'It iS a Great Day.'; var string = str.toUpperCase(); print(string); Output: IT IS A GREAT DAY. In this example the method toUpperCase() converts all the lower case alphabets to their upper case equivalents without affecting the special characters and the
digits. var str = 'It iS a 5r&e@@t Day.' var string = str.toUpperCase(); print(string); Output: IT IS A 5R&E@@T DAY. In this example the method toUpperCase() converts all the lower case alphabets to their upper case equivalents without affecting the special characters and the digits. JavaScript
Output: IT IS A GREAT DAY. Program 2: JavaScript
Output: IT IS A 5R&:AMPE@@T DAY. Supported Browser:
How to convert string to uppercase in JavaScript?JavaScript String toUpperCase()
The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.
How do you make an array of uppercase elements?To convert all array elements to uppercase:
Use the map() method to iterate over the array. On each iteration, call the toUpperCase() method to convert the string to uppercase and return the result.
How to convert lowercase to uppercase JavaScript?JavaScript provides two helpful functions for converting text to uppercase and lowercase. String. toLowerCase() converts a string to lowercase, and String. toUpperCase() converts a string to uppercase.
|