Fixed formatting problems and JSDoc (#131)
* Fixed formatting problems and JSDoc * Added returns for JSDoc
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Countdown
|
||||||
|
* @param {number} i Number
|
||||||
|
*/
|
||||||
const countdown = i => {
|
const countdown = i => {
|
||||||
console.log(i);
|
console.log(i);
|
||||||
// base case
|
// base case
|
||||||
if (i <= 0) {
|
if (i <= 0) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
countdown(i - 1);
|
countdown(i - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Displays a message to the console
|
||||||
|
* @param {string} name Name
|
||||||
|
*/
|
||||||
const greet2 = name => console.log(`how are you, ${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}!`);
|
console.log(`hello, ${name}!`);
|
||||||
greet2(name);
|
greet2(name);
|
||||||
console.log('getting ready to say bye...');
|
console.log("getting ready to say bye...");
|
||||||
bye();
|
bye();
|
||||||
};
|
};
|
||||||
|
|
||||||
greet('adit');
|
greet("adit");
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
const fact = (x) => {
|
/**
|
||||||
if (x === 1) {
|
* Consider the factorial of the number
|
||||||
return 1;
|
* @param {number} x Number
|
||||||
}
|
* @returns {number} Result
|
||||||
|
*/
|
||||||
|
const fact = x => {
|
||||||
|
if (x === 1) return 1;
|
||||||
return x * fact(x - 1);
|
return x * fact(x - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Countdown
|
||||||
|
* @param {number} i Number
|
||||||
|
*/
|
||||||
function countdown(i) {
|
function countdown(i) {
|
||||||
console.log(i);
|
console.log(i);
|
||||||
// base case
|
// base case
|
||||||
if (i <= 0) {
|
if (i <= 0) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
countdown(i - 1);
|
countdown(i - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Displays a message to the console
|
||||||
|
* @param {string} name Name
|
||||||
|
*/
|
||||||
function greet2(name) {
|
function greet2(name) {
|
||||||
console.log('how are you, ' + name + '?');
|
console.log("how are you, " + name + "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a message to the console
|
||||||
|
*/
|
||||||
function bye() {
|
function bye() {
|
||||||
console.log('ok bye!');
|
console.log("ok bye!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a message to the console
|
||||||
|
* @param {string} name Name
|
||||||
|
*/
|
||||||
function greet(name) {
|
function greet(name) {
|
||||||
console.log('hello, ' + name + '!');
|
console.log("hello, " + name + "!");
|
||||||
greet2(name);
|
greet2(name);
|
||||||
console.log('getting ready to say bye...');
|
console.log("getting ready to say bye...");
|
||||||
bye();
|
bye();
|
||||||
}
|
}
|
||||||
|
|
||||||
greet('adit');
|
greet("adit");
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Consider the factorial of the number
|
||||||
|
* @param {number} x Number
|
||||||
|
* @returns {number} Result
|
||||||
|
*/
|
||||||
function fact(x) {
|
function fact(x) {
|
||||||
if (x === 1) {
|
if (x === 1) return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return x * fact(x - 1);
|
return x * fact(x - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user