Array of Strings to UpperCase
Given an array
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' ]
Array of String to UpperCase
- The input will be a single line containing an array myArray
- 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 */
View Discussion
Improve Article
Save Article
View Discussion
Improve Article
Save Article
Below is the example of the String toUpperCase[] Method.
- Example:
JavaScript
function
func[] {
var
str =
'geeksforgeeks'
;
var
string = str.toUpperCase[];
document.write[string];
}
func[];
- Output:
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.
Syntax:
str.toUpperCase[]
Return value:
This method returns a new string in which all the lower case letters are converted to upper case.
Examples for the above method are provided below:
Example 1:
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.
Example 2:
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.
Codes for the above method are provided below:
Program 1:
JavaScript
function
func[] {
var
str =
'It iS a Great Day.'
;
var
string = str.toUpperCase[];
document.write[string];
}
func[];
Output:
IT IS A GREAT DAY.
Program 2:
JavaScript
function
func[] {
var
str =
'It iS a 5r&:ampe@@t Day.'
var
string = str.toUpperCase[];
document.write[string];
}
func[];
Output:
IT IS A 5R&:AMPE@@T DAY.
Supported Browser:
- Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 3 and above
- Opera 3 and above
- Safari 1 and above