logo


JS Assignment-1 _ Bano Qabil

Teacher : Mr. Adil ahmed Shekhani & Student: Bushra Jan _ 40125





1. Write a script to greet your website visitor using JS alert box. (Welcome to Our Website)



2. Write a script to display message on your web page. (Error! Please Enter avalid password)



3. Write a script to display message on your web page: (Hint : Use line break)



4. Write a script to display messages in sequence (3 Alerts)



5. Make use of alerts in your new/existing HTML & CSS project.



6. Practice placement of element in following sections of your project in exercise 5:

    a. Head
    b. Body (before your page's HTML)
    c. Body (inside your page's HTML)
    d. Body (after your page's HTML)

Ans:6
" Head tag "
" Body tag reamain same as before, inside, after "



7. Declare a variable called username & 8. Declare a variable called myName & assign to it a string that represents your Full Name.



9. Write script to

    a. Declare a JS variable, titled message.
    b. Assign “Hello World” to variable message.
    c. Display the message in alert box.


10. Write a script to save student's bio data in JS variables and show the data in alert boxes.



11. Declare a variable called email and assign to it a string that represents your Email Address(e.g. example@example.com). Show the blow mentioned message in an alert box.(Hint: use string concatenation)



12. Write a script to display this in browser through JS. & 13. Store following string in a variable and show in alert and browser through JS “▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬”



14. Declare a variable called age & assign to it your age. Show your age in an alert box.



15. Declare & initialize a variable to keep track of how many times a visitor has visited a web page. Show his/her number of visits on your web page. For example: “You have visited this site N times”.



16. Declare a variable called birthYear & assign to it your birth year. Show the following message in your browser:


17. A visitor visits an online clothing store www.xyzClothing.com . Write a script to store in variables the following information: a. Visitor's name b. Product title c. Quantity i.e. how many products a visitor wants to order Show the following message in your browser: “John Doe ordered 5 T-shirt(s) on XYZ Clothing store”.



18. Declare 3 variables in one statement.



19. Declare 5 legal & 5 illegal variable names.



20.Display this in your browser

    a. A heading stating “Rules for naming JS variables”
    b. Variable names can only contain ______, ______, ______ and ______. For example $my_1stVariable
    c. Variables must begin with a ______, ______ or _____. For example $name, _name or name
    d. Variable names are case _________
    e. Variable names should not be JS _________


21. Write a program that take two numbers & add them in a new variable. Show the result in your browser. & 22.Repeat task21 for subtraction, multiplication, division & modulus.



23. Do the following using JS Mathematic Expressions

    a. Declare a variable.
    b. Show the value of variable in your browser like “Value after variable declaration is: ??”.
    c. Initialize the variable with some number.
    d. Show the value of variable in your browser like “Initial value: 5”.
    e. Increment the variable.
    f. Show the value of variable in your browser like “Value after increment is: 6”.
    g. Add 7 to the variable.
    h. Show the value of variable in your browser like “Value after addition is: 13”.
    i. Decrement the variable.
    j. Show the value of variable in your browser like “Value after decrement is: 12”.
    k. Show the remainder after dividing the variable's value by 3.
    l. Output : “The remainder is : 0”.


24. Cost of one movie ticket is 600 PKR. Write a script to store ticket price in a variable & calculate the cost of buying 5 tickets to a movie.



25. Write a script to display multiplication table of any number in your browser.





Copyright© 2024 _ Bushra Jan _ 40125