Fixed formatting problems and JSDoc (#131)

* Fixed formatting problems and JSDoc

* Added returns for JSDoc
This commit is contained in:
Alexandr Shulaev
2020-09-14 19:46:30 +04:00
committed by GitHub
parent d8da439590
commit 34df0a6d08
6 changed files with 54 additions and 24 deletions

View File

@@ -1,10 +1,11 @@
/**
* Countdown
* @param {number} i Number
*/
const countdown = i => {
console.log(i);
// base case
if (i <= 0) {
return;
}
if (i <= 0) return;
countdown(i - 1);
};

View File

@@ -1,12 +1,23 @@
/**
* Displays a message to the console
* @param {string} name Name
*/
const greet2 = name => console.log(`how are you, ${name}?`);
const bye = () => console.log('ok bye!');
/**
* Displays a message to the console
*/
const bye = () => console.log("ok bye!");
const greet = (name) => {
/**
* Displays a message to the console
* @param {string} name Name
*/
const greet = name => {
console.log(`hello, ${name}!`);
greet2(name);
console.log('getting ready to say bye...');
console.log("getting ready to say bye...");
bye();
};
greet('adit');
greet("adit");

View File

@@ -1,7 +1,10 @@
const fact = (x) => {
if (x === 1) {
return 1;
}
/**
* Consider the factorial of the number
* @param {number} x Number
* @returns {number} Result
*/
const fact = x => {
if (x === 1) return 1;
return x * fact(x - 1);
};

View File

@@ -1,10 +1,11 @@
/**
* Countdown
* @param {number} i Number
*/
function countdown(i) {
console.log(i);
// base case
if (i <= 0) {
return;
}
if (i <= 0) return;
countdown(i - 1);
}

View File

@@ -1,16 +1,27 @@
/**
* Displays a message to the console
* @param {string} name Name
*/
function greet2(name) {
console.log('how are you, ' + name + '?');
console.log("how are you, " + name + "?");
}
/**
* Displays a message to the console
*/
function bye() {
console.log('ok bye!');
console.log("ok bye!");
}
/**
* Displays a message to the console
* @param {string} name Name
*/
function greet(name) {
console.log('hello, ' + name + '!');
console.log("hello, " + name + "!");
greet2(name);
console.log('getting ready to say bye...');
console.log("getting ready to say bye...");
bye();
}
greet('adit');
greet("adit");

View File

@@ -1,7 +1,10 @@
/**
* Consider the factorial of the number
* @param {number} x Number
* @returns {number} Result
*/
function fact(x) {
if (x === 1) {
return 1;
}
if (x === 1) return 1;
return x * fact(x - 1);
}