OneBite.Dev - Coding blog in a bite size

declare a string in Javascript

Code snippet on how to declare a string in Javascript

let str = 'My String';

This code declares a string variable named “str” with a value of “My String”. The first word “let” is a keyword in JavaScript used when declaring a variable. The word “str” is the name of the variable. The equals sign (=) is used to assign a value to the variable, which in this case is the string “My String”. The string in JavaScript is denoted by quotations.

javascript