diff --git a/caseClass.js b/caseClass.js
new file mode 100644
index 0000000..e3a75e2
--- /dev/null
+++ b/caseClass.js
@@ -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
\ No newline at end of file
diff --git a/factorial.js b/factorial.js
new file mode 100644
index 0000000..e592e91
--- /dev/null
+++ b/factorial.js
@@ -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);
+ }
+ }
+ });
\ No newline at end of file
diff --git a/node_modules/smatch/.jshintrc b/node_modules/smatch/.jshintrc
new file mode 100644
index 0000000..abcc4c4
--- /dev/null
+++ b/node_modules/smatch/.jshintrc
@@ -0,0 +1,7 @@
+{
+ "strict": true,
+ "es3": true,
+ "maxlen": 80,
+ "newcap": false,
+ "trailing": true
+}
diff --git a/node_modules/smatch/.npmignore b/node_modules/smatch/.npmignore
new file mode 100644
index 0000000..09d5211
--- /dev/null
+++ b/node_modules/smatch/.npmignore
@@ -0,0 +1,3 @@
+test/
+Gruntfile.js
+dist/
diff --git a/node_modules/smatch/LICENSE b/node_modules/smatch/LICENSE
new file mode 100644
index 0000000..2c9388e
--- /dev/null
+++ b/node_modules/smatch/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Travis Kaufman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/smatch/README.md b/node_modules/smatch/README.md
new file mode 100644
index 0000000..58f4d1f
--- /dev/null
+++ b/node_modules/smatch/README.md
@@ -0,0 +1,276 @@
+smatch
+======
+
+Scala-style pattern matching for Javascript!
+
+smatch is an interpretation of [scala's pattern-matching
+mechanisms](http://www.scala-lang.org/old/node/120) for
+javascript. It uses a declarative API that allows for expression-oriented
+programming, providing maximum code clarity by ridding your code of
+complex and/or verbose conditional logic that's normally needed to check
+objects. This allows you to clearly specify the intent of your program, leading
+to better readability and maintainability.
+
+smatch is built to work in all ES5-compatible environments, and tries to
+make use of any ES6 features when possible.
+
+## Table of Contents
+
+- [Installation](#user-content-installation)
+- [Usage](#user-content-usage)
+ - [Simple Example](#user-content-simple-example)
+ - [How it works](#user-content-how-it-works)
+ - [Matching Objects](#user-content-matching-objects)
+ - [Property Extraction](#user-content-property-extraction)
+ - [Writing your own functions for case_](#user-content-writing-your-own-functions-for-case_)
+ - [Built-in match helper functions](#user-content-built-in-match-helper-functions)
+ - [match.typeOf(typeStr)](#user-content-matchtypeoftypestr)
+ - [match.instanceOf(ctor)](#user-content-matchinstanceofctor)
+ - [match.exactly(obj)](#user-content-matchexactlyobj)
+ - [match.raw(v)](#user-content-matchrawv)
+ - [match.oneOf(…list)](#user-content-matchoneoflist)
+- [License](#user-content-license)
+
+## Installation
+Installation can be done via npm
+
+```sh
+$ npm install smatch
+```
+
+However, a minified, production-ready version, found in the `dist/` dir, can be
+used for browser-based environments.
+
+smatch exposes a single function that is used for pattern-matching, which you
+can access a variety of ways depending on your environment.
+
+Node/CommonJS:
+
+```javascript
+var match = require('smatch');
+// use match ...
+```
+
+AMD/RequireJS:
+
+```javascript
+require(['/path/to/smatch'], function(match) {
+ // start using match...
+});
+```
+
+Plain old Vanilla:
+
+```javascript
+(function(global) {
+ var match = global.match;
+ // start using match ...
+});
+```
+
+## Usage
+
+_Note that the following examples make use of ES6's fat arrow functions for
+maximum readability and conciseness, however regular `function() ...`
+statements can be used in place of these._
+
+### Simple Example
+
+```javascript
+var myMatchFn = (someValue) => match(someValue, function(case_) {
+ case_('foo', 'You got foo');
+ case_('bar', 'You got bar');
+ case_(match.typeOf('string'), 'You got some other string ' + someValue);
+ case_(match.typeOf('number'), 'You got number ' + someValue);
+ case_(match.instanceOf(Date), 'You got a Date');
+ case_(match.ANY, 'You got something else');
+});
+
+console.log(myMatchFn('foo')); // => 'You got foo'
+console.log(myMatchFn('bar')); // => 'You got bar'
+console.log(myMatchFn('a string!')); // => 'You got some other string a string!'
+console.log(myMatchFn(250)); // => 'You got number 250'
+console.log(myMatchFn(new Date())); // => 'You got a date!'
+console.log(myMatchFn({foo: 'bar', baz: 12})); // => 'You got something else'
+```
+
+#### How it works
+
+The `match` function takes any value as its first argument, and a function as a
+second argument that takes one variable, which is itself a function as is used
+to emulate scala's `case` statement, hence why it's called `case_` both
+internally and in these docs.
+
+As soon as a `case_` statement is matched against, it looks at the second argument to the statement and takes the following actions:
+
+* If the argument is not a function, that value is returned to the caller of `match`.
+* If the argument _is_ a function, the return value from invoking that function is returned to the caller of `match`.
+
+`case_` functions, much like the `case` statement, cascade from top to bottom, so if the callback for the first `case_` function where the first argument is matched against will be invoked, and that value will be returned.
+
+The `case_` function works in the following way:
+
+* If a primitive value is specified as the first argument, then it will be compared using `===` to the first argument to `match`, and if they're equal the callback will be invoked.
+* If a _function_ is given, the `case_` statement will call the function and pass it the first argument to `match`. If that function returns any truthy value, it will be considered a match and the callback will be invoked. This is how `match.typeOf`, `match.instanceOf`, and other work: they are all [higher-order functions](http://en.wikipedia.org/wiki/Higher-order_function) that output functions which `case_` invokes.
+* If a non-callable object is given, `case_` takes a series of steps. Read the next section for more info on this…
+
+If there are no matches found, `match.MISS` will be returned. `match.MISS` is a singleton object that will only be returned if _no_ match whatsoever is found.
+
+```javascript
+var m = match('hey', function(case_) {
+ case_('foo', 'blah');
+});
+console.log(m === match.MISS); // => true
+```
+
+### Matching Objects
+
+Matching objects using smatch differs from how one normally treats "object equality" in javascript. When an object is given as the first argument `match`, any object specified as an argument within its `case_` calls _will_ match using the following scheme:
+
+* If the object is a `Date`, `Number`, `Boolean`, or `String`, the result of calling `valueOf()` on both objects is directly compared.
+* If the object is a `RegExp`, the source and flags are compared.
+* Otherwise, for every direct key in the object specified as the first argument to `case_`, if there is a corresponding key in the first argument to `match`, and the values for both of those keys are the same, then the match will be considered valid.
+
+The following example demonstrates this:
+
+```javascript
+var someObject = {foo: 'bar', baz: 1, bing: {bang: 'boom'}};
+var m = match(someObject, function(case_) {
+ case_({foo: 'bar'}, 'Some object with property foo = "bar"');
+ case_(match.ANY, 'Something else');
+});
+
+console.log(m); // => 'Some object with property foo = 'bar'
+```
+
+#### Property Extraction
+
+Objects can also have property values extracted from them to be passed to the callback functions. This is one of the most powerful aspects of pattern matching.
+
+```javascript
+// Logs 'boom'
+match(someObject, function(case_) {
+ case_({bing: {bang: '$0'}}, console.log.bind(console));
+});
+```
+
+The `$N` string is called an _extract token_, and is used to specify that if a property exists for that object, pass it as the `N`th argument to the callback function.
+
+As an example, here's some code that uses `match` to display tweets that a user has retweeted, showing the author name, screen name, and tweet text.
+
+```javascript
+$.ajax({
+ url: 'https://api.twitter.com/1.1/statuses/home_timeline.json',
+ dataType: 'json',
+ headers: {
+ 'Authorization': 'Bearer ' + ACCESS_TOKEN
+ },
+ data: {
+ count: 200
+ }
+}).then(printTweets, handleError);
+
+function printTweets(tweets) {
+ var tweet$Els = tweets.map((tweet) => match(tweet, function(case_) {
+ case_({
+ retweeted: true,
+ user: {
+ name: '$0',
+ screen_name: '$1',
+ },
+ text: '$2'
+ }, (user, sn, text) => $(
+ ['
', user, '(@' + sn + ')', '-', text, '
'].join(' ')
+ ));
+ })).filter((result) => result !== match.MISS);
+
+ $('#tweets').append(tweet$Els);
+}
+```
+
+### Writing your own functions for `case_`
+
+As described above, if `case_` encounters a function as its first argument, it will invoke that function with its value, and will match if the function returns _any_ truthy value. This allows you to easily write your own matching functions for `case_`.
+
+```javascript
+function oddEvenPartition(numbers) {
+ var [odds, evens] = [[], []];
+
+ numbers.forEach(function(n) {
+ match(n, function(case_) {
+ case_((n) => n % 2 === 0, () => evens.push(n));
+ case_(match.ANY, () => odds.push(n));
+ });
+ });
+
+ return [odds, evens];
+}
+```
+
+### Built-in `match` helper functions
+
+While it's easy to write your own matching functions, `match` ships with a number of higher-order matching functions that can be used as the first argument to any `case_` call:
+
+#### match.typeOf(_typeStr_)
+
+Returns a function that will call `typeof` on the value passed to `match()`, and if the returned result matches `typeStr`, it'll be considered a match, _except_ in the case of `null`. `match.typeOf` knows that `null` is _not_ an object, so `null` won't match for `match.typeOf('object')`. To match null type, use `match.typeOf('null')`.
+
+#### match.instanceOf(_ctor_)
+
+Returns a function that will call `instanceof` on the value passed to `match()`, and if that value is an instance of _ctor_, it will be considered a match.
+
+#### match.exactly(_obj_)
+
+Returns a function that deeply compares the value passed to `match()` against `obj`, and will match if they're deeply equal. This differs from normal object matching as objects must appear exactly the same. However Date, String, Number, Boolean, and RegExp objects are compared the same as in regular object matching.
+
+#### match.raw(_v_)
+
+Returns an object that, when it encounters it, tells smatch to use the exact identity of _v_ to the value passed to `match()`, and if they're the same it will be considered a match. This function is useful for testing for object identity, and for matching against strings that would otherwise be considered extract tokens, such as US currency:
+
+```javascript
+match(nycBarPrices, function(case_) {
+ case_(match.raw('$5'), 'PBR/Natty/Keystone');
+ case_(match.raw('$7'), 'Well shot');
+ case_(match.raw('$12'), 'Call drink');
+ case_(match.raw('$20'), 'Premium');
+ case_(match.raw('$50'), 'Top Shelf');
+ case_((v) => parseInt(v.slice(1), 10) > 50), "You"re a tool');
+});
+```
+
+`match.raw()` can also be used inside of objects:
+
+```javascript
+match(prices, function(case_) {
+ case_([match.raw('$3'), match.raw('$4')], () => 'Cheap');
+});
+```
+
+#### match.oneOf(_…list_)
+
+Returns a function that takes a number of arguments and will match if the value passed to `match()` is any one of those specified in list. Uses `===` to compare.
+
+## License
+
+The MIT License (MIT)
+
+Copyright (c) 2013 Travis Kaufman
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/node_modules/smatch/lib/smatch.js b/node_modules/smatch/lib/smatch.js
new file mode 100644
index 0000000..26b3bdf
--- /dev/null
+++ b/node_modules/smatch/lib/smatch.js
@@ -0,0 +1,571 @@
+/**
+ * smatch - A scala-style pattern-matching utility for javascript.
+ *
+ * @author Travis Kaufman
+ * @copyright 2013 Travis Kaufman
+ * @license MIT
+ */
+
+(function(root, factory) {
+ 'use strict';
+ if (typeof define == 'function' && define.amd) {
+ define([], factory);
+ } else if (typeof exports == 'object') {
+ module.exports = factory();
+ } else {
+ root.match = factory();
+ }
+}(this, function() {
+ 'use strict';
+
+ /**
+ * List of primitive types as strings, excluding null.
+ *
+ * @constant {Array.}
+ * @private
+ */
+ var PRIMITIVES = ['undefined', 'number', 'boolean', 'string'];
+
+ /**
+ * List of `[[Class]]`es of ES built-in objects, which can be
+ * tested for equality using valueOf(), instead of enumerating
+ * through each property.
+ *
+ * @constant {Array.}
+ * @private
+ */
+ var VALUECLASSES = ['Number', 'String', 'Date', 'Boolean'];
+
+ /** @see {@link match#MISS} */
+ var MISS = mkSymbol();
+
+ /** @see {@link match#ANY} */
+ var ANY = mkSymbol();
+
+ /**
+ * Used to indicate whether or not this match should be an extraction or not.
+ *
+ * @constant {Symbol}
+ * @private
+ */
+ var EXTRACTION = mkSymbol();
+
+ /**
+ * Used as a property to indicate that a string literal matching an extract
+ * token ("$1", for example) should not be treated as an extract token but as
+ * a literal string.
+ *
+ * @see {@link match#raw}
+ * @constant {Symbol}
+ * @private
+ */
+ var RAW = mkSymbol();
+
+ /**
+ * This is the token used to tell match to extract whatever value it finds at
+ * this position and pass it to the case_ callback function.
+ *
+ * @constant {RegExp}
+ * @private
+ */
+ var EXTRACT_TOKEN = /^\$(\d+)$/;
+
+
+ /**
+ * Emulates Scala's `match` directive. Given a value, and a function
+ * consisting of a number of `case_` calls, this will check each `case_` call
+ * and behave in the following manner:
+ *
+ * * If the first argument to `case_` is a primitive, it will be directly
+ * compared against that value, and if it is equal, will invoke the callback
+ * given as the second argument to it.
+ * * If the first argument is a function, it will call that function with the
+ * value given to match(), and if it returns anything truthy, it will invoke
+ * the callback given as the second argument.
+ * * If the first argument is an object, it will attempt to partially match
+ * against the object. That is, it will make sure that the value given to
+ * match has at _least_ equal properties with the value given. Then, if there
+ * are any extract tokens specified within the object, it will grab all of
+ * them and when it invokes the callback, it will pass each value along in
+ * the position specified by the token. So for example `[0, '$0', '$1']`,
+ * when used as a matcher against the array `[0, 1, 2]` will invoke that
+ * `case_` function's callback with the arguments `(1, 2)`. However, if the
+ * matcher `[0, '$1', '$0']` was used, the `case_` function's callback would
+ * be invoked with arguments `(2, 1)`. Consequently, `[0, '$1', '$2']` will
+ * invoke the callback with arguments `(undefined, 1, 2)`.
+ *
+ * Whenever a case_ function callback is invoked, the return value from that
+ * callback will be returned from `match.`
+ *
+ * If a literal value should be returned as the result of a match, the second
+ * argument to a `case_` function can be simply that value, in which case if
+ * there is a match `case_` case will return the value specified.
+ *
+ * ```
+ * case_('foo', 'you got foo'); // If match, would return 'you got foo'
+ * ```
+ *
+ * @param {*} value - Any value to match against.
+ * @param {Function} partialFn - The function responsible for executing
+ * `case_` statements, and returning a value for a given match. This
+ * function is passed as a single parameter, the `case_` function (or really
+ * whatever you want to call it; in these docs and in the code it's referred
+ * to as `case_`, as this is what the statement is called in Scala), which
+ * can be used to match against values and then return a value if there is
+ * a match. See the examples for more information.
+ * @returns {*} The return value of the invoked callback from the _first_
+ * successfully-matched `case_` call.
+ * @public
+ */
+ var match = function match(value, partialFn) {
+
+ var result = MISS;
+ var isValueNaN = isNaNValue(value);
+
+ var case_ = function(matchValue, fn) {
+ var literalValue, extractions;
+
+ if (result !== MISS) {
+ // We've already found something
+ return;
+ }
+
+ if (typeof fn != 'function') {
+ literalValue = fn;
+ fn = function __matcher__() {
+ return literalValue;
+ };
+ }
+
+ switch (true) {
+ // Check match against the ANY wildcard
+ case matchValue === ANY:
+ // Check if both values are the NaN value
+ case isValueNaN && isNaNValue(matchValue):
+ // Check if both values are primitive and they equal one another
+ case isPrimitive(matchValue) && matchValue === value:
+ // Check if matchValue is a function and if so evaluate the function
+ // using `value` and check if it's truthy
+ case typeof matchValue == 'function' && !!(matchValue(value)):
+ result = setResult(fn(), result);
+ break;
+ // Check if matchValue is an object and if so apply rules for matching
+ // objects.
+ case isObject(matchValue):
+ extractions = partiallyMatchAndExtract(value, matchValue);
+ if (extractions) {
+ result = setResult(fn.apply(null, extractions), result);
+ }
+ break;
+ default:
+ break;
+ }
+ };
+
+ partialFn(case_);
+ return result;
+ };
+
+ /**
+ * Returns a function that tests whether or not a given object is of a certain
+ * type. Note that this function is smart enough not to match `null` with
+ * `typeof` value of 'object'. If you want to check that something is a null
+ * type, use `match.typeOf('null')`, which was going to be standard in ES6
+ * but got rejected because too much pre-existing code is relying on this
+ * quirk :(.
+ *
+ * @param {string} typeStr - The 'type' string.
+ * @returns {Function} A function that accepts an object and tests whether or
+ * not the `typeof` that object is of type `typeStr`.
+ * @memberof match
+ * @public
+ */
+ match.typeOf = function(typeStr) {
+ return function(v) {
+ var t = typeof v;
+ if (v === null) {
+ return typeStr === 'null';
+ }
+
+ return t === typeStr;
+ };
+ };
+
+ /**
+ * Takes a given value and ensures that when it's matched against, it's
+ * always treated as that literal value. This is most commonly used for
+ * matching against strings that resemble extract tokens, such as "$15"
+ *
+ * @param {*} v - The value to ensure is treated literally. Note: If an
+ * object is given to raw(), it will be compared using ===, and not a deep
+ * comparison.
+ * @returns {Object} - Object that's used internally to identify raw, literal
+ * values.
+ * @memberof match
+ * @public
+ */
+ match.raw = function(v) {
+ var o = mkEmptyObj();
+ o[RAW] = v;
+ return o;
+ };
+
+ /**
+ * Returns a function that will check if a given object is an `instanceof`
+ * the constructor passed to this function.
+ *
+ * @param {Function} ctor - The constructor function that will be used in the
+ * `instanceof` check.
+ * @return {Function} A function that takes an object and tests whether or
+ * not it is an instance of the specified constructor function.
+ * @memberof match
+ * @public
+ */
+ match.instanceOf = function(ctor) {
+ return function(v) { return v instanceof ctor; };
+ };
+
+ /**
+ * Returns a function that, when given a value, will return true if and only
+ * if the object is deeply equal to `obj.` This is different than the default
+ * "partially matching" algorithm used by match in that it will ensure that
+ * the object being compared is pretty much idential to `obj`. When we say
+ * "pretty much identical", we mean that for every direct property that
+ * exists in `obj`, there is also that direct property existent on the object
+ * passed in, and the values returned from accessing both properties are
+ * deeply equal.
+ *
+ * @param {*} obj - The value to that will be deeply compared against in the
+ * returned function.
+ * @returns {Function} A function that takes an object and deeply compares it
+ * to `obj`.
+ * @memberof match
+ * @public
+ * @todo Handle circular references within objects.
+ */
+ match.exactly = function(obj) {
+ return function(v) { return deepEqual(obj, v); };
+ };
+
+ /**
+ * Returns a function that, when given a value, checks to make sure that
+ * value is found within the given arguments specified.
+ *
+ * @param {...*} list - One or more positional arguments to check for
+ * inclusion.
+ * @returns {Function} A function that when given a value will return true if
+ * the value is found within that list.
+ * @memberof match
+ * @public
+ */
+ match.oneOf = function(/*...list*/) {
+ var list = Array.prototype.slice.call(arguments);
+ return function(v) { return ~indexOf(list, v); };
+ };
+
+ /**
+ * Sentinel value that's returned from a `match()` call _only_ when no match
+ * has been found for the given value in that function.
+ *
+ * @constant {Symbol}
+ * @memberof match
+ * @public
+ */
+ match.MISS = MISS;
+
+ /**
+ * This can be used in a `case_` call to match against _any_ value given.
+ * This is usually put as the last `case_` call in a `match()` function as it
+ * will catch any value that hasn't already been matched. It is equivalent to
+ * scala's wildcard matcher (`_`).
+ *
+ * @constant {Symbol}
+ * @memberof match
+ * @public
+ */
+ match.ANY = ANY;
+
+ /**
+ * Retrieve the internal [[Class]] property of an object via
+ * `Object.prototype.toString`.
+ *
+ * @param {Object} obj - The object to get the [[Class]] prop from.
+ * @returns {string} The [[Class]] of `obj`.
+ * @private
+ */
+ function klass(obj) {
+ return Object.prototype.toString.call(obj).slice(8, -1);
+ }
+
+ /**
+ * Returns the result of Object.create(null) when available, and a plain
+ * empty object when not.
+ *
+ * @returns {Object}
+ * @private
+ */
+ function mkEmptyObj() {
+ return Object.create(null);
+ }
+
+ /**
+ * Create a symbol if available. If not, create a null object. If
+ * Object.create isnt available, create a plain old object.
+ *
+ * @returns {Symbol} Could be an object, but treated as a symbol.
+ * @private
+ */
+ function mkSymbol() {
+ if (typeof Symbol == 'function') {
+ return Symbol();
+ }
+
+ var o = mkEmptyObj();
+ var DATE_TIME = Date.now();
+ var toString = function() {
+ return ['#', '__sym_', Date.now(), '__'].join('');
+ };
+ var desc = Object.getOwnPropertyDescriptor(Object.prototype, 'toString');
+
+ desc.value = toString;
+ Object.defineProperty(o, 'toString', desc);
+
+ return o;
+ }
+
+ /**
+ * Safely checks whether or not an object directly contains a given property.
+ *
+ * @param {Object} obj - The object to check.
+ * @param {string} prop - The name of the property to check for on the object.
+ * @returns {boolean} True if the property is a direct property of the object.
+ * @private
+ */
+ function hasOwn(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+ }
+
+ var keys = Object.keys;
+
+ /**
+ * Array.prototype.indexOf polyfill, taken straight from MDN.
+ *
+ * @see {@link http://mzl.la/19ZfdDP}
+ * @private
+ */
+ function indexOf(arr, searchEl, fromIndex) {
+ return Array.prototype.indexOf.call(arr, searchEl, fromIndex);
+ }
+
+ /**
+ * Checks whether or not a given value is a primitive.
+ *
+ * @param {*} v - The value to check.
+ * @returns {boolean} True if the value is a primitive, false otherwise.
+ * @private
+ */
+ function isPrimitive(v) {
+ return v === null || ~indexOf(PRIMITIVES, typeof v);
+ }
+
+ /**
+ * Checks whether or not a given value is an object, but not a function.
+ *
+ * @param {*} v - The value to check.
+ * @returns {boolean} True if the value is a non-callable object,
+ * false otherwise.
+ * @private
+ */
+ function isObject(v) {
+ return v !== null && typeof v == 'object';
+ }
+
+ /**
+ * Check to see if a given value is exactly NaN.
+ *
+ * @param {*} v - The value to check.
+ * @returns {boolean} True if the value is the NaN value, false otherwise.
+ * @private
+ */
+ function isNaNValue(v) {
+ return typeof v == 'number' && isNaN(v);
+ }
+
+ /**
+ * Used to set the final result from a call to match(). Used internally by
+ * the case_() function. Will only set the result if it hasn't already been
+ * set.
+ *
+ * @param {*} v - The value to set the result as
+ * @param {*} result - The current result within the match() function.
+ * @returns {*} Either the value passed in if there isn't already a result
+ * set, or the current result if there is.
+ * @private
+ */
+ function setResult(v, result) {
+ if (result === MISS) {
+ return v;
+ }
+
+ return result;
+ }
+
+ /**
+ * Given a string, will return the value representing the position in which
+ * partiallyMatchAndExtract should place the value this extraction represents
+ * in.
+ *
+ * @param {string} str - The string that may or may not have an extract token.
+ * @returns {(string|undefined)} Either the string representing the index to
+ * place the extraction, or undefined indicating that this string is not an
+ * extract token.
+ * @see {@link partiallyMatchAndExtract}
+ * @private
+ */
+ function extract(str) {
+ return (str.match(EXTRACT_TOKEN) || [])[1];
+ }
+
+ /**
+ * Tests two RegExp objects to see if they're equal by comparing their source
+ * strings and flags.
+ *
+ * @param {RegExp} r1 - The regex to compare.
+ * @param {RegExp} r2 - The regex to compare against.
+ * @returns {boolean} True if r1.source === r2.source and r1's flags === r2's
+ * flags.
+ * @private
+ */
+ function areRegexesEqual(r1, r2) {
+ return (
+ r1.source === r2.source &&
+ r1.ignoreCase == r2.ignoreCase &&
+ r1.global === r2.global &&
+ r1.multiline === r2.multiline
+ );
+ }
+
+ /**
+ * Ensure that matcher has _at least_ the same deeply equal keys as obj.
+ * matcher does not have to have _all_ of the keys obj has, but every key
+ * in matcher must be present in `obj` and have the same value. Also looks for
+ * extraction tokens and substitues each of them into an array.
+ *
+ * @param {Object} obj - The object to partially match against.
+ * @param {Object} matcher - The object containing that will be partially
+ * matched with `obj.`
+ * @param {Array} [extractions=[]] - A list of extractions that have already
+ * been pulled out of a partial match with between `obj` and `matcher`. Used
+ * internally by the function.
+ * @return {?Array} List of extractions, if any, from the object.
+ * Returns null if the partial match fails.
+ * @private
+ */
+ function partiallyMatchAndExtract(obj, matcher/*, extractions=[]*/) {
+ var k, matcherItem, objItem, extIdx;
+ var objVal, matcherVal;
+ var extractions = arguments[2] === undefined ? [] : arguments[2];
+ var objClass = klass(obj), matcherClass = klass(matcher);
+
+ if (objClass == 'RegExp' || matcherClass == 'RegExp') {
+ return areRegexesEqual((obj || {}), (matcher || {})) ? [] : null;
+ }
+
+ if (
+ ~indexOf(VALUECLASSES, objClass) ||
+ ~indexOf(VALUECLASSES, matcherClass)
+ ) {
+ return (obj && obj.valueOf()) === (matcher && matcher.valueOf()) ?
+ [] : null;
+ }
+
+ for (k in matcher) {
+ if (hasOwn(matcher, k)) {
+ if (!hasOwn(obj, k)) {
+ return null;
+ }
+
+ matcherItem = matcher[k];
+ objItem = obj[k];
+
+ if (
+ typeof matcherItem == 'string' &&
+ (extIdx = extract(matcherItem))
+ ) {
+ extractions[extIdx] = objItem;
+ continue;
+ } else if (hasOwn(matcherItem, RAW)) {
+ // Extract any raw values and turn them into the matcherItem.
+ matcherItem = matcherItem[RAW];
+ }
+
+ if (
+ isPrimitive(matcherItem) && isPrimitive(objItem) &&
+ matcherItem === objItem
+ ) {
+ continue;
+ } else if (isPrimitive(matcherItem) || isPrimitive(objItem)) {
+ return null;
+ } else if (
+ !partiallyMatchAndExtract(objItem, matcherItem, extractions)
+ ) {
+ return null;
+ }
+ }
+ }
+
+ return extractions;
+ }
+
+ /**
+ * Check that one object deeply equals another. Used with match.exactly().
+ *
+ * @param {Object} o1 - Object to compare.
+ * @param {Object} o2 - Object to compare against.
+ * @returns {boolean} True if the objects are deeply equal, false otherwise.
+ * @see {@link match#exactly}
+ */
+ function deepEqual(o1, o2) {
+ var isO1Primitive = isPrimitive(o1);
+ var isO2Primitive = isPrimitive(o2);
+ var o1Class = klass(o1);
+ var o2Class = klass(o2);
+ var k;
+
+ if (isO1Primitive && isO2Primitive) {
+ // Either both are NaN, or both are equal
+ return isNaNValue(o1) ? isNaNValue(o2) : o1 === o2;
+ }
+
+ if (isO1Primitive || isO2Primitive) {
+ // Primitives !== Objects
+ return false;
+ }
+
+ if (o1Class == 'RegExp' || o2Class == 'RegExp') {
+ return areRegexesEqual(o1, o2);
+ }
+
+ if (~indexOf(VALUECLASSES, o1Class) || ~indexOf(VALUECLASSES, o2Class)) {
+ return (o1 && o1.valueOf()) === (o2 && o2.valueOf());
+ }
+
+ if (keys(o1).length != keys(o2).length) {
+ return false;
+ }
+
+ for (k in o1) {
+ if (hasOwn(o1, k)) {
+ if (hasOwn(o2, k) && deepEqual(o1[k], o2[k])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ return match;
+}));
diff --git a/node_modules/smatch/package.json b/node_modules/smatch/package.json
new file mode 100644
index 0000000..38628fb
--- /dev/null
+++ b/node_modules/smatch/package.json
@@ -0,0 +1,83 @@
+{
+ "_args": [
+ [
+ "smatch",
+ "/home/kim/Desktop/projects/BackendCodeChallengeSeptember2018"
+ ]
+ ],
+ "_from": "smatch@latest",
+ "_id": "smatch@0.0.2",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/smatch",
+ "_npmUser": {
+ "email": "travis.kaufman@gmail.com",
+ "name": "traviskaufman"
+ },
+ "_npmVersion": "1.4.26",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "smatch",
+ "raw": "smatch",
+ "rawSpec": "",
+ "scope": null,
+ "spec": "latest",
+ "type": "tag"
+ },
+ "_requiredBy": [
+ "#USER"
+ ],
+ "_resolved": "https://registry.npmjs.org/smatch/-/smatch-0.0.2.tgz",
+ "_shasum": "bed13225535020b9c56657b84d32ac14b6b65cb0",
+ "_shrinkwrap": null,
+ "_spec": "smatch",
+ "_where": "/home/kim/Desktop/projects/BackendCodeChallengeSeptember2018",
+ "author": {
+ "email": "travis.kaufman@gmail.com",
+ "name": "Travis Kaufman"
+ },
+ "bugs": {
+ "url": "https://github.com/traviskaufman/smatch/issues"
+ },
+ "dependencies": {},
+ "description": "Scala-style pattern matching for Javascript",
+ "devDependencies": {
+ "chai": "~1.8.1",
+ "cyclonejs": "~1.0.0",
+ "grunt": "~0.4.2",
+ "grunt-contrib-jshint": "~0.7.2",
+ "grunt-contrib-uglify": "~0.2.7",
+ "grunt-mocha-test": "~0.8.1",
+ "jshint": "~2.3.0",
+ "mocha": "~1.15.1",
+ "sinon": "~1.7.3",
+ "traceur": "0.0.9"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "bed13225535020b9c56657b84d32ac14b6b65cb0",
+ "tarball": "https://registry.npmjs.org/smatch/-/smatch-0.0.2.tgz"
+ },
+ "gitHead": "f485045cd0ff6431be009c35a923618a3011001e",
+ "homepage": "https://github.com/traviskaufman/smatch",
+ "license": "MIT",
+ "main": "lib/smatch.js",
+ "maintainers": [
+ {
+ "name": "traviskaufman",
+ "email": "travis.kaufman@gmail.com"
+ }
+ ],
+ "name": "smatch",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/traviskaufman/smatch.git"
+ },
+ "scripts": {
+ "pretest": "grunt jshint",
+ "test": "grunt mochaTest"
+ },
+ "version": "0.0.2"
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..5326337
--- /dev/null
+++ b/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "BackendCodeChallengeSeptember2018",
+ "version": "1.0.0",
+ "description": "## Simple Unchanging Rules The code challenge is and will always be judged using the following criteria: - A Correct fork, branch and pull request - Using the GitHub Pull Request Time Stamp and correct code quality & structure, the first developer whose code runs successfully wins - Code quality and structure will be evaluated - The order for pull requests will be followed, first come first win basis! - Do not share any code that you cannot opensource on the Git Repository as its open source and Africa's Talking will not be liable for any breach of intellectual property (if any) once shared on the platform.",
+ "main": "factorial.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/kimani-mbuguah/BackendCodeChallengeSeptember2018.git"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/kimani-mbuguah/BackendCodeChallengeSeptember2018/issues"
+ },
+ "homepage": "https://github.com/kimani-mbuguah/BackendCodeChallengeSeptember2018#readme"
+}
diff --git a/patternMatching.js b/patternMatching.js
new file mode 100644
index 0000000..a43c1ac
--- /dev/null
+++ b/patternMatching.js
@@ -0,0 +1,17 @@
+const match = require('smatch');
+let myMatchFn = (testValue) => match(testValue, function(case_) {
+ case_('Geek', 'Howdy geek');
+ case_('nerd', 'We love nerds');
+ case_(match.typeOf('string'), 'You got some other string ' + testValue);
+ case_(match.typeOf('number'), 'You got number ' + testValue);
+ case_(match.instanceOf(Date), 'You got a Date');
+ case_(match.ANY, 'You got something else');
+});
+
+console.log(myMatchFn('Geek')); // => 'You got geek'
+console.log(myMatchFn('nerd')); // => 'You got nerd'
+console.log(myMatchFn('Galana Plaza, Kilimani!')); // => 'You got some other string a string!'
+console.log(myMatchFn(2)); // => 'You got an integer 2'
+console.log(myMatchFn(2.23)); // => 'You got a float 2.23'
+console.log(myMatchFn(new Date())); // => 'You got a date!'
+console.log(myMatchFn({foo: 'bar', baz: 12})); // => 'You got something else'
\ No newline at end of file
diff --git a/prime_numbers.js b/prime_numbers.js
new file mode 100644
index 0000000..8bbb5e5
--- /dev/null
+++ b/prime_numbers.js
@@ -0,0 +1,39 @@
+function getPrimeNumbers(inputValue){
+ //Take user input and return a list of all prime numbers between 0 and the user input
+ console.log('List of all prime numbers between 0 and ' + inputValue);
+ for (let counter = 0; counter <= inputValue; counter++) {
+
+ let notPrime = false;
+ for (let i = 2; i <= counter; i++) {
+ if (counter%i===0 && i!==counter) {
+ notPrime = true;
+ }
+ }
+ if (notPrime === false) {
+ console.log(counter);
+ }
+ }
+}
+// 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 in the command line.");
+
+// When user input 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
+ {
+ let number = parseInt(data);
+ getPrimeNumbers(number);
+ }
+});
\ No newline at end of file
diff --git a/scalaRegexExpression.js b/scalaRegexExpression.js
new file mode 100644
index 0000000..c0a0ff2
--- /dev/null
+++ b/scalaRegexExpression.js
@@ -0,0 +1,10 @@
+function testFn(testString){
+ //test if the string contains an integer
+ let matches = testString.match(/\d+/g);
+ if (matches != null) {
+ console.log('This string contains the number 7');
+ }else{
+ console.log('The number 7 was not found in this string');
+ }
+}
+testFn('7th floor Galana plaza, Kilimani');
\ No newline at end of file