Source: http://www.cril.univ-artois.fr/~paris/cours/javascript/tp1JavascriptSolution.pdf