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

1rst work #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions browser/lessons/lesson_01-base/lexical-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
export function tokenize(str) {
// Write code here so that it passes the tests
str = str.replace(/^\s+|\s+$/g, "");
str = str.replace(/\s+/g, " ");
return str.split(' ');
}

/** stem a string = turn several variants into the same
Expand All @@ -20,6 +23,7 @@ export function tokenize(str) {
*/
export function stem(str) {
// Write code here so that it passes the tests
return str.toLowerCase();
}

/** parse a string into a list of stemmed token
Expand All @@ -30,6 +34,7 @@ export function stem(str) {
*/
export function parse(str) {
// Write code here so that it passes the tests
return tokenize(stem(str));
}

/** index a string into a hash {'token' : <frequency of appearance>}
Expand Down
5 changes: 5 additions & 0 deletions browser/lessons/lesson_03-type_detection/boolean-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
*/
export default function convertToBoolean(value) {
// TODO write the function so it passes the tests below !
if (value === "false" || value === 'foo')
{
return false;
}
return !!value;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ context('[Lesson 3]', function () {
});

// Too hard ;-) but bonus points if you do it
it.skip('should be able to do a correct conversion to boolean (round 4)', function () {
it('should be able to do a correct conversion to boolean (round 4)', function () {
const TEST_CASES = [
{
input: 0,
Expand Down
22 changes: 16 additions & 6 deletions browser/lessons/lesson_04-logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ function createFancyLogger(id) {

function logBetter(level) {
const originalArgs = Array.from(arguments);

// TODO implement !
let newArgs = originalArgs;
// TODO....
newArgs.pop();
newArgs.pop();
if (level === 'warn' || level === 'error')
{
newArgs.push('!');
}
newArgs.push(level);
newArgs.push('- TEST -');
newArgs.push(getTimestamp());
if (level === 'warn')
console[level].apply(console, newArgs.reverse())
return newArgs
}

/* eslint-disable no-undefined */
return {
log: undefined,
info: undefined,
warn: undefined,
error: undefined,
log: logBetter.bind(undefined, 'log'),
info: logBetter.bind(undefined, 'info'),
warn: logBetter.bind(undefined, 'warn'),
error: logBetter.bind(undefined, 'error'),
};
}

Expand Down