[JS Practice] Filter invalid login

Title :

Filter invalid login


While developing a website, you detect that some of the members have troubles logging in. Searching through the code you find that all logins ending with a “_” make problems. So you want to write a function that takes an array of pairs of login-names and e-mails, and outputs an array of all login-name, e-mails-pairs from the login-names that end with “_”.

If you have the input-array:

[ [ "foo", "foo@foo.com" ], [ "bar_", "bar@bar.com" ] ]

it should output

[ [ "bar_", "bar@bar.com" ] ]

Continue reading


[JS Practice] Functional Addition

Title :

Functional Addition


Create a function add(n) which returns a function that always adds n to any number

var addOne = add(1);
addOne(3); // 4

var addThree = add(3);
addThree(3); // 6

Continue reading

[JS practice] javascript prototype Trim a String(重写trim方法)

Title :
Trim a String(重写javascript中的trim方法)

Description :
Extend the String prototype by a trim function, that returns the string with leading or trailing whitespaces removed.


PS: Of course, the original trim function was removed before 😉

Continue reading