JavaScript Practical Tasks

Task #1

Ex: 1

          
            for (var i = 0; i < 10; i++) {
              setTimeout(function() {
                  console.log(i);
              })
            };
          
        

What will be the output in the console and why?

Answer:

Taks #2

Ex: 1


Write a JavaScript program to display the current day and time in the following format.
Sample Output :

Today is : Friday.
Current time is : 4 PM : 50 : 22

Answer:

Ex: 2


Write a JavaScript function that reverse a number.

Example x = 32243;
Expected Output : 34223

Answer:

Ex: 3


Write a JavaScript program to calculate the factorial of a number.
In mathematics, the factorial of a non-negative integer n, denoted by n!,
is the product of all positive integers less than or equal to n.

For example, 5! = 5 x 4 x 3 x 2 x 1 = 120

Answer:

Ex: 4


Write a JavaScript program that accept two integers and display the larger.

Answer:

Ex: 5


Write a simple JavaScript program to join all elements
of the following array into a string.
Sample array : myColor = ["Red", "Green", "White", "Black"];

Expected Output :
"Red,Green,White,Black"
"Red+Green+White+Black"

Answer:

Ex: 6


Write a JavaScript function to get the month name from a particular date.
Test Data :

month_name(new Date("10/11/2009"));
month_name(new Date("11/13/2014"));

Output :
"October"
"November"


Answer:

Ex: 7


Write a JavaScript program to test the first character of a string is uppercase or not


Answer:

Ex: 8


Write a JavaScript program to draw a smile

Task #4

Exercise: 1


There is a layout on the page


Ядра в вёдра, выдру в тундру!
Выдрав с выдры в тундре гетры
В недрах тундры, выдры в гетрах
Вытру гетрой выдре морду
Тырят в вёдра ядра кедров!
Вытру выдрой ядра кедров


It is necessary to turn to each tag in turn in the right order,
and print their contents to the console in order to get
a meaningful tongue twister.

Answer:

Click and check the console

Exercise: 2


There is a layout on the page


Element 1
Element 2
Element 3
Element 4
Element 5
Element 6


Using JS, you need to set the first three elements to red text,
and the remaining three to green.

Answer:

Exercise: 3


description image of ex3

Answer:

Click and check the console


    Exercise: 4


    Answer:

    What is Lorem Ipsum?

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.

    Where does it come from?

    Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. from "The Extremes of Good and Evil" by Cicero

    Why do we use it?

    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.

    Exercise: 5


    Answer:

    Milk 1 l. x2
    Cola 1.5 l. x1
    Bread x2
    Cheese x1
    Chocolate bar x3

    Exercise: 6


    Answer: