0% found this document useful (0 votes)
19 views5 pages

2 VariablesForStrings

This document outlines a series of JavaScript assignments focused on declaring and using variables for strings. Tasks include creating variables for a username, full name, and email, displaying messages in alert boxes, and constructing a fortune teller program. The assignments aim to enhance understanding of variable declaration and string manipulation in JavaScript.

Uploaded by

irizwana055
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

2 VariablesForStrings

This document outlines a series of JavaScript assignments focused on declaring and using variables for strings. Tasks include creating variables for a username, full name, and email, displaying messages in alert boxes, and constructing a fortune teller program. The assignments aim to enhance understanding of variable declaration and string manipulation in JavaScript.

Uploaded by

irizwana055
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

 

   

VARIABLES  FOR  STRINGS  

Assignment  #  2  
JAVASCRIPT  
MODULE  A    -­‐  Mobile  &  Cloud  Computing  
VARIABLES  FOR  STRINGS  |  JAVASCRIPT  
 

1. Declare a variable called username.


2. Declare a variable called myName & assign to it a string
that represents your Full Name.
3. Write a script to
a. declare a JS variable, titled message
b. assign “Hello World” to the variable message
c. display the message in alert box
4. Write a script to save student’s bio data in JS variables
and show the data in alert boxes. Example:

Page  1  of  4  
 
VARIABLES  FOR  STRINGS  |  JAVASCRIPT  
 

5. Write a script to display the following alert using one JS


variable:

6. Fortune Teller: Why pay a fortuneteller when you can


just program your fortune yourself?
Store the following into variables: number of children,
partner’s name, geographic location, and job title.
Page  2  of  4  
 
VARIABLES  FOR  STRINGS  |  JAVASCRIPT  
 

Output your fortune like:

7. Declare a variable called email & assign to it a string that


represents your Email Address (e.g. [email protected]). Show
the below mentioned message in an alert box. (Hint: use
string concatenation)

8. Declare a variable called book & give it the value “A


smarter way to learn JavaScript”. Display the following
message in an alert box:

Page  3  of  4  
 
VARIABLES  FOR  STRINGS  |  JAVASCRIPT  
 

9. Use the variables, declared in exercise 4 & show the details


giving meaning to data. Like “My name is Ali Khan”, “I am
17 years old”, “I study in SSUET”, “I take Mobile & Cloud
Computing, Module A classes”
10. Write a script to display this in browser through JS

-- END --

Page  4  of  4  
 

You might also like