New Lab Report 2024 Unit1
New Lab Report 2024 Unit1
Instructions:
Create your new repository on GitHub and push your lab solution to GitHub with new
branch for each lab set.
Share your repository to [email protected] as a collaborator.
Print and attach your updated GitHub screenshot into lab set
Format
● Cover (Print)
● GitHub Screenshot
● Lab Question –hand written
● Introduction –hand written
● Syntax and Format –hand written
● Code –hand written
● Output(Print)- With full URL
Lab-1
1. Write a JavaScript function that reverse a number.
2. Write a JavaScript function that returns a passed string with letters in alphabetical order.
Example string: 'webmaster'
Expected Output: 'abeemrstw'
3. Write a JavaScript function that accepts a string as a parameter and counts the number of
vowels within the string.
4. Write a JavaScript function that accepts a string as a parameter and converts the first
letter of each word of the string in upper case.
5. Write a JavaScript program to get the current date. Expected Output : mm-dd-yyyy,
mm/dd/yyyy or dd-mm-yyyy, dd/mm/yyyy, yyyy month date day
6. Write a JavaScript program to calculate number of days left until next Christmas.
7. Write a JavaScript program to calculate addition, subtraction, multiplication and division
of two numbers (input from user).
8. Write a JavaScript program that accept two integers and display the larger and smaller.
9. Write a JavaScript program that accept three integers and display the larger and smaller.
10. Write a JavaScript program that accept n number of integers into array and display the
larger.
11. Write a JavaScript program that accept n number of integers into array and display the
smaller.
12. Write a JavaScript function to check whether an `input` is an array or not
13. Write a simple JavaScript program to join all elements of the following array into a string
14. Write a JavaScript program to sort the items of an array.
Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
Sample array : var arr1 = [ 3, 8, 7, 6, 5, -4, 3, 2, 1 ]; Sample Output : -4,-3,1,2,3,5,6,7,8
15. Write a JavaScript program to display the colors in the following way :
Here is the sample array: color = ["Blue ", "Green", "Red", "Orange", "Violet", "Indigo",
"Yellow "]; o = ["th","st","nd","rd"]
Output
"1st choice is Blue ."
"2nd choice is Green."
"3rd choice is Red."
16. Write a JavaScript for loop that will iterate from 0 to 15. For each iteration, it will check
if the current number is odd or even, and display a message to the screen.
17. Write a JavaScript conditional statement to find the largest of five numbers. Display an
alert box to show the result taking input using prompt
18. Write a JavaScript function to get difference between two dates in days.
19. Write a JavaScript program to calculate age taking input using form.
20. Write a JavaScript function to get time differences in days between two dates.
21. Write a JavaScript function to get the weekend date.
22. Write a JavaScript function to check whether a string is blank or not.
23. Write a JavaScript function to remove specified number of characters from a string
24. Write a JavaScript program to perform following task.
a. Create an empty object called dog
b. Print the the dog object on the console
c. Add name, legs, color, age and bark properties for the dog object. The bark
property is a method which return woof woof
d. Get name, legs, color, age and bark value from the dog object
e. Set new properties the dog object: breed, getDogInfo
25. Create an object literal called personAccount. It has firstName, lastName, incomes,
expenses properties and it has totalIncome, totalExpense, accountInfo,addIncome,
addExpense and accountBalance methods. Incomes is a set of incomes and its description
and expenses is a set of incomes and its description.
26. Write a function called tenMostFrequentWords which get the ten most frequent word from
a string taking user input from user?
27. Write JavaScript program to perform following steps of task for DOM manipulation
a. Create an index.html file and put four p elements as above: Get the first paragraph
by using document.querySelector(tagname) and tag name
b. Get each of the the paragraph using document.querySelector('#id') and by their id
c. Get all the p as nodeList using document.querySelectorAll(tagname) and by their
tag name
d. Loop through the nodeList and get the text content of each paragraph
e. Set a text content to paragraph the fourth paragraph,Fourth Paragraph
f. Set id and class attribute for all the paragraphs using different attribute setting
methods
g. Change stye of each paragraph using JavaScript(eg. color, background, border,
font-size, font-family)
Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
h. Select all paragraphs and loop through each elements and give the first and third
paragraph a color of green, and the second and the fourth paragraph a red color
i. Set text content, id and class to each paragraph
28. Develop the following application; use the following HTML elements to get started with.
You will get the same code on starter folder. Apply all the styles and functionality using
JavaScript only.
a. The year color is changing every 1 second
b. The date and time background color is changing every on seconds
c. Completed challenge has background green
d. Ongoing challenge has background yellow
e. Coming challenges have background red
<div class="wrapper">
<h1>Asabeneh Yetayeh challenges in 2020</h1>
<h2>30DaysOfJavaScript Challenge</h2>
<ul>
<li>Python Challenge Done</li>
<li>JavaScript Challenge Ongoing</li>
<li>React Challenge Coming</li>
<li>FullStack Challenge Coming</li>
<li>DataAnalysis Challenge Coming</li>
<li>ReactNative Challenge Coming</li>
<li>MachineLearning Challenge Coming</li>
</ul>
</div>
29. Create a div container on HTML document and create 0 to 100 numbers dynamically and
append to the container div.
a. Even numbers background is green
b. Odd numbers background is yellow
c. Prime numbers background is red
30. Write JavaScript program that use countries array to display 50 countries into tabular
format 6 countries in a row.
31. Write JavaScript program that generate numbers from 1 to user input number and
marking evens, odds and prime numbers with three different colors
32. Write JavaScript program to generate following program counter
33. Write JavaScript program to create following calculator and calculate result accordingly
Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
34. Create analog clock using HTML, CSS and JavaScript
Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]
38. Write JavaScript program with different button and paragraph and perform following
event according to button pressed
Change Change Hide Show Increase Decrease Reset Change
Background Paragraph Paragraph Paragraph font Size by font Size font into Text
Background 2pt. by 2pt. 12 pt. Color
39. Design and validate form with following condition using HTML, CSS and JavaScript.
a. Form field: Name, Address, Username, Email, Password, Website, Phone,
Gender(Radio), Course(Dropdown),
b. Name Validation: We check to make sure the name field is not empty and does
not contain any numbers.
c. Username Validation: We check to make sure the username field is not empty and
does not contain any spaces and special character except underscore (_).
d. Phone Validation: We check to make sure the phone field is not empty, does not
contain any character except numbers, and should start with [98/97/96].
e. Gender Validation: We check the gender field is not empty.
f. Address Validation: We check that the address field is not empty.
g. Email Validation: We make sure that the email field is not empty and that it
includes the “@” symbol.
h. Password Validation: We ensure that the password field is not empty and that the
password is at least eight characters long with at least one digit, one upper case
character, one lowercase character and one special character.
i. Course Selection Validation: We check that a course has been selected from a
dropdown list.
Thank you
Compiled by: Basanta Chapagain – BCA Scripting Language 4th SEM [[email protected]]