[JS Practice] Anagram Detection

Title :

Anagram Detection


According to wikipedia :

An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; for example Doctor Who can be rearranged into Torchwood.

An anagram is the result of rearranging the letters of a word to produce a new word. (Ref wikipedia).

Note: anagrams are case insensitive


  • foefet is an anagram of toffee
  • Buckethead is an anagram of DeathCubeK

The challenge is to write the function isAnagram to return true if the word test is an anagram of the word original and false otherwise.

Continue reading

[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

[wget] create log file in /root directory

Context :

System : Ubuntu 12.04
Techs : shell(bash)

I have a bash shell script who calls a web service. The web service is wrote in PHP and it will return true if everything is OK.
The method that I execute the calling service is like this :

wget -T 0 http://host/program/myurl > /tmp/mylog

Problem :

Every time I execute the script shell with root, it will generate a file which is called myurl.x (x will be replaced by numbers) in my /root directory instead of in the /tmp/mylog, and this file contains only a number : 1, which I thought it means true.

Continue reading

[JS Practice] Valid The Coupon Code

Title :

Valid The Coupon Code


Your online store likes to give out coupons for special occasions. Some customers try to cheat the system by entering invalid codes or using expired coupons.

Your mission:
Write a function called checkCoupon to verify that a coupon is valid and not expired. If the coupon is good, return true. Otherwise, return false.

A coupon expires at the END of the expiration date. All dates will be passed in as strings in this format: “June 15, 2014″

Continue reading

[JS Practice] Christmas day

Title :

Christmas day


Sometimes it’s useful to know on which day of week the holly holiday will occur.
But just don’t limit ourselves to this year and write a function which consumes a Christmas date and outputs a name of weekday.


findOutChristmasWeekday('2013 12 25') // returns 'Wednesday'

Only valid Christmas dates will be passed to the function.

Date parameter could be a string or a Date object. If it’s a string here are possible date parameter formats:

'2013 12 25'
'12 25 2013'
'25 December 2013'

Note: calendar used in the kata is Gregorian.

Continue reading