OneBite.Dev - Coding blog in a bite size

format a string in Javascript

Code snippet on how to format a string in Javascript

  let myString = "Welcome to programming!";
  let formatedString = myString.toUpperCase();   

This code takes a string, “Welcome to programming!”, and formats it into an uppercase string by using the method “.toUpperCase()“. This method is used to change a string to upper case letters. In this example, the string “Welcome to programming!” is saved in the variable “myString” and then the “.toUpperCase()” method is used to format it. Then the formatted string is saved in the variable “formattedString”. The result would be “WELCOME TO PROGRAMMING!”

javascript