×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

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();

Parameters

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

Sample Input/Output

Input: "Hello World!"
Output: "HELLO WORLD!"
Input: "Hello123@"
Output: "HELLO123@"

Example

<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 = "Hello123@"; 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 = Hello123@
new_str = HELLO123@

JavaScript String Object Methods »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.