0% found this document useful (0 votes)
55 views

Assignment 1 JS

1. JavaScript is a programming language used primarily in web browsers to create dynamic and interactive experiences for users. Most internet functionality is built with JavaScript. 2. JavaScript has several data types including Boolean, Null, Undefined, Number, BigInt, String, and Symbol. 3. JavaScript can be used to build websites, web applications, presentations, server applications, web servers, games, and more.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Assignment 1 JS

1. JavaScript is a programming language used primarily in web browsers to create dynamic and interactive experiences for users. Most internet functionality is built with JavaScript. 2. JavaScript has several data types including Boolean, Null, Undefined, Number, BigInt, String, and Symbol. 3. JavaScript can be used to build websites, web applications, presentations, server applications, web servers, games, and more.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

S.

Mapped Bloom’s
Assignment Statement
No COs Level

Define JavaScript with its signification.


JavaScript is a programming language used primarily by Web
1. browsers to create a dynamic and interactive experience for the CO1 K2
user. Most of the functions and applications that make the
Internet indispensable to modern life are coded in some form of
JavaScript.
List out the different data types in JavaScript. CO1 K3
Boolean type.
Null type.
Undefined type.
2. Number type.
BigInt type.
String type.
Symbol type.

What can be build using JavaScript? CO1 K2


Websites:
Web Applications:
Presentations:
Server applications:
3. Web Servers:
Games:
Art:
Smartwatch apps:

What is an an array? Explain any three array methods in CO1 K2


JavaScript using suitable example.

An array is a collection of similar data elements stored at


contiguous memory locations. It is the simplest data structure
where each data element can be accessed directly by only using
4 its index number

every() Checks if every element in an array pass a test

fill() Fill the elements in an array with a static value

filter() Creates a new array in an array that pass a test


5. Discuss any five math functions in JavaScrip CO1 K4

Here are some of the most commonly used functions, and their
graphs:
Linear Function: f(x) = mx + b.
Square Function: f(x) = x2
Cube Function: f(x) = x3
Square Root Function: f(x) = √x.
Absolute Value Function: f(x) = |x|
Reciprocal Function. f(x) = 1/x.
What is an operator? Explain any four types of operators in JavaScript C K2
using suitable example for each. O
1
Operators are special symbols that perform specific operations on one,
two, or three operands, and then return a result. As we explore the
operators of the Java programming language, it may be helpful for you to
know ahead of time which operators have the highest precedence.

1 Java Arithmetic Operators


Arithmetic operators are used to perform arithmetic operations on
variables and data. For example,

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulo Operation (Remainder after division)


6.

2. Java Assignment Operators


Assignment operators are used in Java to assign values to variable
= a = b; a = b;

+= a += b; a = a + b;

-= a -= b; a = a - b;

*= a *= b; a = a * b;

/= a /= b; a = a / b;

%= a %= b; a = a % b;

3. Java Relational Operators


Relational operators are used to check the relationship between two
operands. For example,
OperatorDescriptionExample == Is Equal To 3 == 5 returns false != Not
Equal To 3 != 5 returns true > Greater Than 3 > 5 returns false < Less
Than 3 < 5 returns true >= Greater Than or Equal To 3 >= 5 returns
false <= Less Than or Equal To 3 <= 5 returns true
4. Java Logical Operators
Logical operators are used to check whether an expression
is true or false. They are used in decision making.
Operator Example Meaning

&&
expression1 && true only if both expression1 and
(Logical
expression2 expression2 are true
AND)

||
expression1 || true if either expression1 or
(Logical
expression2 expression2 is true
OR)

! (Logical true if expression is false and


!expression
NOT) vice versa
What are conditional statements in JavaScript? Explain. C K3
O
Conditional statements control behavior in JavaScript and determine 1
whether or not pieces of code can run.

There are multiple different types of conditionals in JavaScript including:


7. “If” statements: where if a condition is true it is used to specify execution
for a block of code.
“Else” statements: where if the same condition is false it specifies the
execution for a block of code.
“Else if” statements: this specifies a new test if the first condition is false.

8. Write JavaScript code to prompt the user to enter a number. Add a button C K4
in your html page and on 'click' event of the button a function named O
'calFact()' should be called which will calculate the factorial of the 1
number entered by the user.

1. <!DOCTYPE html>  
2. <html>  
3. <head>  
4. </head>  
5. <body style = "text-align: center; font-size: 20px;">  
6. <h1> Welcome to the javaTpoint.com </h1>  
7. Enter a number: <input id = "num">  
8. <br><br>  
9. <button onclick = "fact()"> Factorial </button>  
10. <p id = "res"></p>  
11. <script>  
12. function fact(){  
13. var i, num, f;  
14. f = 1;  
15. num = document.getElementById("num").value;  
16. for(i = 1; i <= num; i++)    
17. {  
18. ff = f * i;  
19. }  
20. ii = i - 1;    
21. document.getElementById("res").innerHTML = "The factorial 
of the number " + i + " is: " + f ;  
22. }  
23. </script>  
24. </body>  
25. </html>  

You might also like