-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek5.js
More file actions
84 lines (65 loc) · 1.64 KB
/
Week5.js
File metadata and controls
84 lines (65 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//alert('hello');
// for (initializer; condition; increment)
const students = ['Emily', 'Rory', 'Octopus'];
for(let i=0; i <students.length; i++){
console.log('Hello ' + students[i]);
}
let sum = 0;
for(let i = 0; i < 100; i+=20){
sum = sum + i;
}
console.log(sum);
//function nameOfFunction(parameter, parameter){
//code/logic
//}
//Call function
function product(a, b){
x = a*b;
console.log(x);
}
product(2, 3);
function sayHi(){
console.log('Hi');
}
sayHi();
function add(value1, value2){
sum = value1 + value2
console.log(sum);
}
//const times = multiply(10, 20);
//console.log(times);
//function myname(){
//let name = promt('what is your name?');
// console.log(name);
//}
//myname();
function movie(title, released){
return title + ' was released on ' + released;
}
var movie1 = movie('Avengers', '2019');
console.log(movie1);
//WEEK 6
var person = {
name: 'Emily',
age: '300',
eyeColour: 'hazel',
friends: ['Rory', 'Octopus', 'Dinosaur'],
sayHello: function() {
console.log('Hello');
}
};
console.log('Name is ', person.name);
console.log('Friends are ', person.friends);
console.log('Favourite is ', person.friends[0]);
person.sayHello();
var jsHeader = document.getElementById('jsHeader');
jsHeader.addEventListener('click', function(){
jsHeader.style.color = 'red'
});
//document.addEventListener('DOMContentLoaded', function(){
//alert('Hi welcome')
//});
var div = document.getElementById('div');
var words = document.createElement('p');
words.innerText = 'Hiya';
div.append(words);