Home » JavaScript

String toUpperCase() Method with Example in JavaScript

JavaScript String toUpperCase() Method: Here, we are going to learn about the toUpperCase() method of the string in JavaScript with Example.
Submitted by IncludeHelp, on February 05, 2019

String toUpperCase() Method

toUpperCase() Method is a string method in JavaScript, it is used to converts all alphabets in uppercase and returns the new string with uppercase alphabets.

Syntax:

    new_string = str.toUpperCase();

Here,

  • str is the main string to be converted.
  • new_string is the returned new string with all alphabets in uppercase.

Examples:

    Input: "Hello World!"
    Output: "HELLO WORLD!"
    Input: "[email protected]"
    Output: "[email protected]"

Code:

<html>
<head>
<title>JavaScipt Example</title>
</head>

<body>
<script>		
	var main_str = "Hello World!";
	var new_str = main_str.toUpperCase();
	document.write("main_str =  " + main_str + "<br>");
	document.write("new_str =  " + new_str + "<br>");

	main_str = "[email protected]";
	new_str = main_str.toUpperCase();
	document.write("main_str =  " + main_str + "<br>");
	document.write("new_str =  " + new_str + "<br>");	
</script>
</body>
</html>

Output

main_str = Hello World!
new_str = HELLO WORLD!
main_str = [email protected]
new_str = [email protected]





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.