Skip to content

Commit a0d6cfb

Browse files
committed
add void func
1 parent e20d29b commit a0d6cfb

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

choose-script.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const colorCyan = "\x1b[36m%s\x1b[0m";
99
const colorPurple = "\x1b[35m%s\x1b[0m";
1010
const colorRed = "\x1b[31m%s\x1b[0m";
1111

12-
(function(){
12+
void function(){
1313
let messageEmptyDir = () => {
1414
console.log(colorRed, 'Sorry, there are no scripts in "scripts" directory.')
1515
console.log(colorCyan, 'Change it and create first script on javascript in "scripts" dir!');
@@ -30,11 +30,12 @@ const colorRed = "\x1b[31m%s\x1b[0m";
3030
jsFiles.forEach((file, index) => {
3131
console.log(colorCyan, `[${index}]: ${file}`);
3232
});
33+
console.log(colorRed, `[!]: exit`)
3334

3435
execScript(jsFiles);
3536
}
3637
});
37-
})();
38+
}();
3839

3940
/**
4041
* Execute choosen script
@@ -67,6 +68,10 @@ let execScript = (files) => {
6768
}
6869

6970
rl.question('What do you want to exec? Write index of script: ', (answer) => {
71+
if (answer === '!') {
72+
rl.close();
73+
return;
74+
}
7075
if (isValidIndex(answer)) {
7176
rl.close();
7277
tryExecute(files[answer]);

scripts/compare.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* “Каким будет результат этих выражений?”
55
* Excerpt From: Ilya Kantor. “Язык программирования JavaScript”. Apple Books.
66
*/
7-
(function(){
7+
void function(){
88
console.log(5 > 4); //true
99
console.log("ананас" > "яблоко"); //false
1010
console.log("2" > "12"); //false => wrong => true
1111
console.log(undefined == null); //true
1212
console.log(undefined === null); //false
1313
console.log(null == "\n0\n"); //false
1414
console.log(null === +"\n0\n"); //false
15-
})()
15+
}()

scripts/if-testing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ let rewriteFunctions = function() {
9898
};
9999

100100

101-
(function(){
101+
void function(){
102102
ask('Какое «официальное» название JavaScript?', validateJsName)
103103
.then(x => console.log(x))
104104
.then(() => ask('Write any number', getNumberSign))
105105
.then(x => console.log(x))
106-
})();
106+
}();

scripts/read-user-input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* “Создайте страницу, которая спрашивает имя у пользователя и выводит его.”
55
* Excerpt From: Ilya Kantor. “Язык программирования JavaScript”. Apple Books.
66
*/
7-
(function() {
7+
void function() {
88
let rl = require('readline');
99
let r = rl.createInterface({
1010
input: process.stdin,
@@ -14,4 +14,4 @@
1414
r.close();
1515
console.log('> Welcome, ' + answer);
1616
});
17-
})()
17+
}()

scripts/work-with-vars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* Excerpt From: Ilya Kantor. “Язык программирования JavaScript”. Apple Books.
1010
*/
1111

12-
(function() {
12+
void function() {
1313
let admin;
1414
let name;
1515

1616
name = 'John';
1717
admin = name;
1818

1919
console.log(admin);
20-
})()
20+
}()

0 commit comments

Comments
 (0)