CSS Notes CH 2
CSS Notes CH 2
CODE-22519
Examination Scheme
Theory-100
Practical-50
COURSE OUTCOMES(COs)
a) Create interactive web pages using program flow control structure.
b) Implement arrays and functions in javascript.
c) Create event based web forms using javascript.
d) Use javascript for handling cookies.
e) create interactive webpages using regiular expressions for validations.
f) Create menus and navigations in web pages
Unit-2 Array, Function and String
Total-14 Marks
• Looping an Array:
Example: const num=[10,20,30,40];
let text= “ ”;
num.forEach(fun);
function fun(value){
txt += value + “<br>”;
}
Unit-2 Array, Function and String
• Adding an Element:
Example: const stud=[“abc”, “xyz”, “....”];
stud.push(“a”, “b”);
• Sorting an Array element:
Example: stud.sort();
• Combining an array elements into a string:
Example: let txt = stud.join(“and”);
• Changing Elements of an array:
Example: const index=1;
const newValue=20;
Unit-2 Array, Function and String
• Array Example:
<!DOCTYPE html>
<html>
<body>
<h1>Javascript Arrays</h1>
<script>
var sports= [“Cricket”, “Football”, “Hockey”];
document.write(“Array is=” +sports);
var fruits= [“Banana”, “Orange”, “Apple”, “Mango”];
str=fruits.toString();
document.write(“Array to String=” +str);
len=fruits.length;
document.write(“Length of Fruits Array=” +len);
</script>
</body>
Unit-2 Array, Function and String