-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyperskill-project-2.js
More file actions
77 lines (58 loc) · 1.8 KB
/
hyperskill-project-2.js
File metadata and controls
77 lines (58 loc) · 1.8 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
const input = require('sync-input');
function greet(bot_name, birth_year) {
console.log("Hello! My name is " + bot_name + ".");
console.log("I was created in " + birth_year + ".");
}
function remind_name() {
console.log("Please, remind me your name.");
let name = input();
console.log("What a great name you have, " + name + "!");
}
function guess_age() {
console.log("Let me guess your age.");
console.log("Enter remainders of dividing your age by 3, 5 and 7.");
let rem3 = Number(input());
let rem5 = Number(input());
let rem7 = Number(input());
let age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105;
console.log("Your age is " + age + "; that's a good time to start programming!");
}
function count() {
console.log("Now I will prove to you that I can count to any number you want.");
let number = Number(input());
let current = 0;
while (current <= number) {
console.log(current + " !");
current += 1;
}
}
function test() {
console.log("Let's test your programming knowledge.");
const test = {
1: "To repeat a statement multiple times.",
2: "To decompose a program into several small subroutines.",
3: "To determine the execution time of a program.",
4: "To interrupt the execution of a program"
}
let rightAnswer = 2;
console.log("Why do we use methods?");
for (const [key, value] of Object.entries(test)) {
console.log(`${key}. ${value}`);
}
while (true) {
let answer = Number(input());
if (answer === rightAnswer) {
console.log("Congratulations, have a nice day!");
break;
}
console.log("Please, try again.");
}
}
function end() {
console.log("Completed, have a nice day!");
}
greet('Aid', '2020') // change it as you need
remind_name();
guess_age();
count();
test();