forked from AustinCodingAcademy/JS211_CurrentDateTimeProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
162 lines (112 loc) · 3.64 KB
/
main.js
File metadata and controls
162 lines (112 loc) · 3.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// **THIS IS INCREDIBLY IMPORTANT THAT YOU DO BOTH SECTIONS!!! You will be doing only front-end work in 421 and you need to brush up on your HTML elements**
// ***************************
// PART ONE
// ***************************
// Write a JavaScript program to display the current day and time, start with:
console.log(new Date)
const displayDate = () => {
const currentDate = new Date()
document.getElementById("display-element").innerHTML = currentDate;
}
// Below is a JavaScript program to convert a number to a string.
const b = 10;
console.log(typeof b);
b.toString(b);
console.log(typeof b);
// Below is a JavaScript program that came with the Git.
const num = () => {
const num = 31
document.getElementById("display-number1").innerHTML = num;
document.getElementById("display-number1").toString(num);
}
// Write a JavaScript program to convert a string to the number.
const a = '10';
console.log(typeof a);
a.toNumber(a);
console.log(typeof a);
// Write a JavaScript program that takes in different datatypes and prints out whether they are a:
// * Boolean
// * Null
// * Undefined
// * Number
// * NaN
// * String
// Data types
const number = 10;
console.log (typeof number);
const string = 'This is a string';
console.log(typeof string);
console.log(typeof true);
console.log(typeof undefinedValue);
console.log(typeof null === 'null');
// Write a JavaScript program that adds 2 numbers together.
const num1 = 10
const num2 = 15
const addSum = (x, y) => {
console.log(x + y)
document.getElementById("display-number2").innerHTML = addSum;
document.getElementById("display-number2").toString(addSum);
}
addSum(num1, num2);
// Write a JavaScript program that runs only when 2 things are true.
const firstNumber = 42;
const secondNumber = 31;
console.log(typeof firstNumber);
console.log(typeof secondNumber);
const addBoth=(x, y)=>{
if (x < y && y > 0) {
return (y - x)
}
else {
return 'this will be negative'
}
}
addBoth(firstNumber, secondNumber)
// Write a JavaScript program that runs when 1 of 2 things are true.
const thirdNumber = 25;
const fourthNumber = 16;
console.log(typeof thirdNumber);
console.log(typeof fourthNumber);
const subtractBoth=(x, y)=>{
if (x < y || y > 10) {
return (y - x)
}
else {
return 'this will be negative'
}
}
subtractBoth(thirdNumber, fourthNumber)
// Write a JavaScript program that runs when both things are not true.
const nameOne = 'Taylor';
const nameTwo = 'Tipton';
console.log(typeof nameOne);
console.log(typeof nameTwo);
const fullName=(x, y)=>{
if (typeof x === Number && typeof y === Number) {
return 'My name is not a number'
}
else {
return 'My name is Taylor Tipton'
}
}
fullName(nameOne, nameTwo)
// Adding two numbers together
const addTwo = (x,y) => {
const x = document.getElementById('input1').value;
const y = document.getElementById('input2').value;
const result = x + y;
}
// ***************************
// PART TWO
// ***************************
// 1. download Live-Server by Ritwick Dey,
// 2. reload VS Code,
// 3. click the "Go Live" button
// 4. Go local host 5500 or http://127.0.0.1:5500/index.html to see your web page
// 5. Or go use the `npm start` command and navigate to localhost:8080 (ctrl + C to close)
// 6. go to `index.html`
// 7. create inputs, buttons and event listeners that render the code blocks you built above to the DOM.
// Additional Resources
// Video1: https://player.vimeo.com/video/377147232
// Video2: https://www.youtube.com/embed/bkvH28PXLWc
// Video3: https://www.youtube.com/embed/TrGI9Yki-24