Javascript Assignment
Javascript Assignment
JavaScript Questions:-
01. Create a variable.js file and declare variables and assign string, boolean,
undefined and null data types, Display all the value with their data type.
02. Declare variables to store your first name, last name, marital status, country
and age and display them using interploation method.
03. Declare a varibale and assign string value to it and change all the string
characters to capital letters using toUpperCase() method.
04. Declare a varibale and assign string value to it and check if the string
contains a word Script using includes() method.
05. Declare a varibale and assign string value to it and then split it into an
array using split() method
06. 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon' split the string at
the comma and change it to an array.
07. Declare an array containing the multiple values and use lastIndexOf to
determine the position of the first and last occurrence of a word "pw skills".
08. Demonstrate the use of trim() to remove any trailing whitespace at the
beginning and the end of a string.
10. Figure out the result of the following comparison expression first without
using console.log(). After you decide the result confirm it using console.log()
- 4 > 3
- 4 >= 3
- 4 < 3
- 4 <= 3
- 4 == 4
- 4 === 4
- 4 != 4
- 4 !== 4
- 4 != '4'
- 4 == '4'
- 4 === '4'
- Find the length of python and jargon and make a falsy comparison statement.
12. Create a human readable time format using the Date time object
- YYYY-MM-DD HH:mm
- DD-MM-YYYY HH:mm
- DD/MM/YYYY HH:mm
13. Get user input using prompt(“Enter your age:”). If user is 18 or older , give
feedback:'You are old enough to drive' but if not 18 give another feedback stating
to wait for the number of years he needs to turn 18.
14. Even numbers are divisible by 2 and the remainder is zero. How do you check, if
a number is even or not using JavaScript? Create a program which checks that the
given number is even or odd.
15. Write a program which can give grades to students according to theirs scores:
- 80-100, A
- 70-89, B
- 60-69, C
- 50-59, D
- 0-49, F
16. Check if the season is Autumn, Winter, Spring or Summer. If the user input is :
- September, October or November, the season is Autumn.
- December, January or February, the season is Winter.
- March, April or May, the season is Spring
- June, July or August, the season is Summer
18. Write a program which tells the number of days in a month, now consider leap
year.
19. Create a countries.js file and store the countries name into this file, create
a file web_techs.js and store the popular web technology names into this file.
Access both file in a third file named main.js
21. In countries array check if 'Ethiopia' exists in the array if it exists print
'ETHIOPIA'. If it does not exist add to the countries list.
23. Write a program to check that the number given by the user is a prime number or
not.
24. Write a program to create two array "even" and "odd" having even and odd number
between the 0 to 100 (0 and 100 included).
26. Write a program to print the table of any number given by the user. The format
of the output should be smiliar to the below example-
If the number given by the user is 2 then the output should look like this-
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6 and so on till 2 * 10 = 20.
27. Write a program to print all the prime number between 0 to 100 (0 and 100
included).
28. Write a program to print the given patterns using the loops-
a. Print a triangle pattern, if the given input is 3 then the pattern should
be similar to the given output
*
**
***
29. Write a javascript program which takes the input of filename as string and
prints the extension of the file in the console.
30. Create a simple calculator program in JavaScript which can perform the
addition, substraction, multiplication and division on given numbers.