SPI-Apprenticeship-2023-24--JavaScript

JavaScript Assignments

Assignment 1

Q1.1) WAP to print Welcome to JavaScript message on page load.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.2) WAP to find the higher number from 2 numbers by using Prompt and Alert box.

Hint: By using prompt box enter two numbers then print higher number by using alert box.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.3) Create a distance convertor in HTML that will convert meters in K.Ms.

Hint: Take an input from textbox and print result in another textbox. Formula: 1KM=1000 M

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.4) WAP to print the table of a given number.

Hint: Take an input from textbox and print result in textarea.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.5) Create an HTML page to find the reverse of a number.

Hint: Take an input from textbox and print result in another textbox on buttonโ€™s click. Ex: Input: 123 Output: 321

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.6) Create a simple calculator by using if statement in JavaScript.

Hint: Take two textboxes for getting inputs for calculation and take one textbox to display Result. Take four buttons for operations like + , - , * and /. It looks like as:-

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q1.7) WAP to print the following pattern by using JS:

(a)

*
* * 
* * * 
* * * * 
* * * * *

(b)

* * * * *
* * * *
* * *
* *
*

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview


Assignment 2

Q2.1) Create an HTML page to get and set the content in/ from a div tag by using JavaScript.

Hint: Read content of div and write some content in div by using JS. Take two buttons one is for reading the content of div and another button is for writing the content in div tag.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q2.2) Create an HTML page to show or hide a div tag also create a button to print the content of page.

Hint: Take two anchor tags one is for hiding the div and another anchor tag is to make it visible.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q2.3) Create an HTML page. Display a slider with 5 images. Image should be changed every 3 second.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview

Q2.4) Create an HTML page. Add some content to It. Create a button with text Open Popup. On button click display the modal. Add a button in Modal with text Close Popup. On button click hide the modal.

Ans) ๐Ÿ’ป Code ๐Ÿช„ Live Preview