This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addNumber(a, b) { | |
//check to see that 'a' and 'b' are numbers | |
if (typeof a !== "number" || typeof b !== "number") { | |
return "first and second parameter's must be numbers"; | |
} | |
/* sum both numbers */ | |
let sum = a + b; | |
/* if it's an Integer return 'sum', else for floating point numbers approximate to two decimal place*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addNumber(a, b) { | |
return typeof a !== "number" || typeof b !== "number" | |
? "first and second parameter's must be numbers" | |
: Number((a + b).toFixed(2)); | |
} | |
/* Export the addNumber function to app.test.js */ | |
module.exports = addNumber; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* a userArray to serve as database for storing Users */ | |
let userArray = []; | |
/* create an Id variable set it to zero and auto increment it each time the user constructor is called */ | |
let id = 0; | |
/* A User constructor to create users */ | |
function User(name) { | |
this.name = name; | |
accountBalance = this.accountBalance = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* import the User constructor*/ | |
const User = require("./user_constructor").User; | |
//..create dummy users for test purposes | |
let userOne = new User("John Doe"); | |
let userTwo = new User("Jane Doe"); | |
let userThree = new User("Bill Clinton"); | |
describe("testing that the constructor function returns an object", function() { | |
it("should return 'object'", function() { |