Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.html
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JavaScript Lab</title>
</head>

<body>
hello
<script type="text/javascript" src="index.js"></script>
<script type="module" src="index.js"></script>
</body>
</html>

</html>
42 changes: 32 additions & 10 deletions index.js
Expand Up @@ -5,18 +5,40 @@
that's new and different. That's because we're avoiding a well-known, but
sneaky bug that we'll cover in the next few lessons!

As a result, the lessons for this function will pass *and* it will be available
for you to use if you need it!
As a result, the lessons for this function will pass *and* it will be available for you to use if you need it!
*/

let allWagesFor = function () {
let eligibleDates = this.timeInEvents.map(function (e) {
return e.date
})
let eligibleDates = this.timeInEvents.map(function (e) {
return e.date;
});

let payable = eligibleDates.reduce(function (memo, d) {
return memo + wagesEarnedOnDate.call(this, d)
}.bind(this), 0) // <== Hm, why did we need to add bind() there? We'll discuss soon!
let payable = eligibleDates.reduce(
function (memo, d) {
return memo + wagesEarnedOnDate.call(this, d);
}.bind(this),
0
); // <== Hm, why did we need to add bind() there? We'll discuss soon!

return payable
}
return payable;
};

class Transaction {
constructor(amount, date, memo) {
this.amount = amount;
this.date = date;
this.memo = memo;
}

computeTotal() {
return this.#amountTimesTen() + 100;
}

#amountTimesTen() {
return this.amount * 10;
}
}

function amountTimesTen(transaction) {
return transaction.amount * 10;
}
38 changes: 19 additions & 19 deletions test/helpers.js
@@ -1,24 +1,24 @@
const chai = require('chai')
global.expect = chai.expect
global.chai = chai
const fs = require('file-system')
const jsdom = require('mocha-jsdom')
const path = require('path')
const babel = require('babel-core');
const spies = require('chai-spies')
// const chai = require('chai')
// global.expect = chai.expect
// global.chai = chai
// const fs = require('file-system')
// const jsdom = require('mocha-jsdom')
// const path = require('path')
// const babel = require('babel-core');
// const spies = require('chai-spies')

chai.use( spies );
// chai.use( spies );

const html = fs.readFileSync(path.resolve(__dirname, '..', 'index.html'), 'utf-8')
// const html = fs.readFileSync(path.resolve(__dirname, '..', 'index.html'), 'utf-8')

const babelResult = babel.transformFileSync(
path.resolve(__dirname, '..', 'index.js'), {
presets: ['env']
}
);
// const babelResult = babel.transformFileSync(
// path.resolve(__dirname, '..', 'index.js'), {
// presets: ['env']
// }
// );

const src = babelResult.code
// const src = babelResult.code

jsdom({
html, src
});
// jsdom({
// html, src
// });