Building the Right Environment to Support AI, Machine Learning and Deep Learning
StringsAny series of characters between quotes is called a string. (You'll be seeing lots of strings throughout this book.) Strings are a basic type of information, like numbers--and like numbers, you can assign them to variables.
To assign a string to a variable, you'd write something like this:
var my_name = "thau!";The word thau! is the string assigned to the variable my_name.
You can stick strings together with a plus sign (+), as shown in the bolded section of Figure 2-6. This code demonstrates how to write output to your page using strings.
Line-by-Line Analysis of Figure 2-6Line X in Figure 2-6,
var first_part = "there are ";assigns the string "there are" to the variable first_part. Line Y,
var last_part = " seconds in a day.";sets the variable last_part to the string "seconds in a day." Line Z glues together the values stored in first_part, seconds_per_day, and last_part. The end result is that the variable whole_thing includes the whole string you want to print to the page, there are 86400 seconds in a day. The window.document.write() line then writes whole_thing to the web page.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...