Assignment 1 JS
Assignment 1 JS
Mapped Bloom’s
Assignment Statement
No COs Level
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.
+ Addition
- Subtraction
* Multiplication
/ Division
+= 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;
&&
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)
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>