A
A
Alexander2019-01-14 16:19:48
JavaScript
Alexander, 2019-01-14 16:19:48

How to write an if else condition?

How to write a condition correctly:

if (в корне находится папка с именем folder) {
   выполнить что-то
} else {
   выполнить что-то другое
}

Let me explain, you need to check if there is a folder in the root, do something, if the folder is not in the root, do something else.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-01-14
@Vlad_IT

Use fs.existsSync() It will work something like this

var fs = require('fs');

if (fs.existsSync('./folder')) {
   // выполнить что-то
} else {
   // выполнить что-то другое
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question