Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions caseClass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Person {

constructor(name,age) {
this.name = name;
this.age = age;
}

get age() {
return this._age;
}

set age(value) {
if (value < 0) {
console.log('Hello ' + this.name + ' The age cannot be a negative value');
return;
}
this._age = value;
}

}
let user = new Person('John',22);
console.log(user.age); //returns 22

user = new Person('John',-15); // logs an error message
38 changes: 38 additions & 0 deletions factorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function FirstFactorial(num) {

let factorial = 1;

for (let i = 1; i <= num; i++) {
factorial = factorial * i;
}

console.log(factorial);

}

//Get process.stdin as the standard input object.
let standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.
console.log("Please input an integer: ");

// When user inputs data and click enter key.
standard_input.on('data', function (data) {

// User input exit.
if(data === 'exit\n'){
// Program exit.
console.log("User input complete, program exit.");
process.exit();
}else
{
//return a List of all the factorials of the numbers between 0 and user input
let number = parseInt(data);
for (let counter = 0; counter <= number; counter++) {
FirstFactorial(counter);
}
}
});
7 changes: 7 additions & 0 deletions node_modules/smatch/.jshintrc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions node_modules/smatch/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/smatch/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

276 changes: 276 additions & 0 deletions node_modules/smatch/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading