Class IX-Comp. Sc.-Assignment On JavaScript (Chpater 3 and 4 Till Arithmetic Operators)
Class IX-Comp. Sc.-Assignment On JavaScript (Chpater 3 and 4 Till Arithmetic Operators)
COMPUTER SCIENCE
ASSIGNMENT - JAVASCRIPT (CHAPTER 3 AND 4 TILL arithmetic operators)
1. What is Jscript?
2. Write any two advantages of JavaScript.
3. JavaScript code can be inserted within the HEAD as well as the BODY tags
4. Differentiate between internal JavaScript file and external JavaScript file.
5. Also specify the advantage of using an external JavaScript file.
6. Write the code in HTML to load an external JavaScript file “proj.css”. 3.
7. What are variables used for? Are the variables ABC and Abc same in JavaScript?
Justify your answer.
8. What is the role of comments in JavaScript?
9. Why do we use toString( ) method? Give an example.
10. Which of the following are valid/ invalid variables? If invalid, give reasons also.
a. 9class
b. result
c. first name
d. .xyz
e. first_position
11. Write the equivalent expressions for the following in JavaScript.
a) volume = 3.14 r 3 b) z = 2t + 2y c) s = b2 – 4ac
12. Why is typecasting required.? Differentiate between parseInt() and parseFloat()
conversion functions with an example.
13. Write JavaScript statements (syntax) to
a. Assign the value present in variable “X” to variable “Y”
b. Print the string “Monday”
c. Increase the value of the variable “pr” by 1.
d. Increase the value of the variable “counter” by 3
14. Predict the output
a. alert(parseFloat(34));
b. alert(parseInt(34.5));
c. alert(parseFloat(“25aa”));
d. alert(parseInt(“aa25”));
15. Predict the output
<script language="JavaScript">
var a = "534";
var b = 53;
var c = parseInt(a)+b;
var d = a+b;
document.write("parseInt(a)+b = "+c);
document.write(" a+b = "+d);
</script>
1
16. Predict the output
var a=20; var b= 40; var c=”90”; var d;
document.write(a+b);
document.write(a.toString()+b);
document.write(a.toString()+c);
document.write(parseInt(c)+b);
document.write(parseFloat(a)+parseInt(b));
document.write(a.toString()+b.toString());
document.write(a+d);
17. Identify the errors in the following code and rewrite the correct code. Also underline
the changes made.
<Script language=javascript>
var m; n
10=m;
n=M+*2;
var c=Prompt(“enter a number”);
Document.display(“the value stored in c is “+ c);
<script>