Training / JavaScript
- Challenges It will maybe hurt a bit, but for your good! π΅
- Recall One way to see if you are comfortable with the JS. πΌ
- Cookie Clicker We just sell cookies to earn more cookies! πͺ
- Codecademy π«π· π¬π§
- Learn X in Y minutes π«π· π¬π§
- OpenClassrooms - Apprenez Γ coder avec JavaScript π«π·
- Apprendre Javascript : le JS Γ Simplon β Rodolphe π«π·
- Speaking JavaScript: An In-Depth Guide for Programmers π¬π§
- Eloquent JavaScript π¬π§
- JavaScript Garden π¬π§
- JavaScript The Right Way π¬π§
- JavaScript is Sexy π¬π§
Simplonline
- JavaScript Promo 4 π«π·
- JavaScript - Algo (partie 1) π«π·
Mozilla Developer Network
- https://developer.mozilla.org/fr/docs/Web/JavaScript π¬π§
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript π¬π§
- https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Using_the_W3C_DOM_Level_1_Core π¬π§
- https://developer.mozilla.org/fr/docs/Web/API/Document/getElementById π«π·
- https://developer.mozilla.org/fr/docs/Web/API/Element/innertHTML π«π·
- https://developer.mozilla.org/fr/docs/Web/JavaScript/Guide/Utiliser_les_objets π«π·
- https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Mots_r%C3%A9serv%C3%A9s π«π·
Style Guides
- Google JavaScript Guide π¬π§
- AirBNB ES5 Style Guide π¬π§
GitHub Awesome Lists
-
Essential Javascript Links π¬π§
-
https://github.com/MostlyAdequate/mostly-adequate-guide β€οΈ β€οΈ
- Cours sur le framework AngularJS
- Cours sur la bibliothèque Underscore.js
- Modifier la clΓ© dβune propriΓ©tΓ© dβun objet JS
- Cours sur jQuery : histoire et usage
- Exercices de JS des cours de soutien
- Cours sur JavaScript
- Exercices Frontend (html, css, js)
To be continued..
/*
* Triangle
*
* INPUT:
* - a number N
*
* OUPUT: (eg for N=5)
* #
* ##
* ###
* ####
* #####
*
*/
function Line(N) {
return "#".repeat(N);
}
function Triangle(N) {
for (var i = 1; i <= N; ++i) {
console.log(Line(i));
}
}
Triangle(5);
Triangle(3);
/*
* Factorial
* n! = 1 * 2 * .. * n
*
* 5! = 5 * 4 * 3 * 2 * 1 = 120
*/
// MATHS:
// 0! = 1
// n! = n * (n - 1)!
function fac(n) {
if (n <= 1) {
return 1;
} else {
return n * fac(n - 1);
}
}
/* TEST */
fac(5);
/*
* INPUT: a number N
*
* OUPUT: f(N) where f is the fibonacci function :
*
* 0 1 1 2 3 5 8 13 21 34 ..
*
* f(0) => 0
* f(1) => 1
* f(2) => 0 + 1 = 1
* f(3) => 1 + 1 = 2
* f(4) => 1 + 2 = 3
* f(5) => 2 + 3 = 5
* f(6) => 3 + 5 = 8
* f(7) => 5 + 8 = 13
* ...
*
* /!\ MATHS /!\
*
* f(0) = 0
* f(1) = 1
* f(n) = f(n - 1) + f(n - 2)
*/
function f(N) {
// PUT YOUR CODE HERE !!!
// return the Nth number of the fibonnaci sequence
}
// TEST CODE
console.log("Here 50 first fibonnaci numbers");
for (var i = 0; i < 50; ++i) {
console.log("f(" + i + ") = " + f(i));
}
/*
* f(0) = 0
* f(1) = 1
* f(n) = f(n-1) + f(n-2)
*/
function fib(x) {
if (x == 0)
return 0;
else if (x == 1)
return 1;
else
return fib(x-1) + fib(x-2);
}
/* TEST */
for (var i = 0; i < 100; i++) {
console.log("fib(" + i + ") = " + fib(i));
}
//
// O(n) = 2^n
// => 2^60 = 1152921504606846976
//
var T = [];
T[0] = 0;
T[1] = 1;
for (var i = 2; i < 100; i++) {
T[i] = T[i-2] + T[i-1];
}
function fib(x) {
return T[x];
}
/* TEST */
for (var i = 0; i < 100; i++) {
console.log("fib(" + i + ") = " + fib(i));
}
//
// O(n) = n
// => 60
//
/* ###### CONSTANT ###### */
var BILLS = [200, 100, 50, 20, 10, 5, 2, 1] // ARRAY of bills with really cheap bills like coins
/* ###### SMART ALGORITHM ###### */
var cash_machine = function (amount) { // FUNCTION
var i = 0; // iterator
while (amount > 0) { // check if their is still money to give for the customer
if (BILLS[i] <= amount) { // try with the larger bill
console.log("Cash Machine give me a bill of " + BILLS[i] + "β¬"); // GIVE ME MY MONEY!!!
amount = amount - BILLS[i]; // reduce the amount of money we still have to gave for the customer
} else { // try with a smaller bill
i = i + 1; // increment i variable of 1
}
}
}
/* ###### TESTS ###### */
cash_machine(42);
//cash_machine(25);
//cash_machine(128);
//cash_machine(201);
//cash_machine(1024);
var BILLS = [100, 200, 20, 50, 10];
var cash_machine = function (amount) {
BILLS.sort(function(a, b) { return a < b });
var i = 0;
while (amount > 0) {
if (BILLS[i] <= amount) {
console.log("Give me a bill of " + BILLS[i] + "β¬");
amount = amount - BILLS[i];
} else if (i < BILLS.length) {
i = i + 1;
} else {
console.log("It lack " + amount + "β¬");
break;
}
}
}
cash_machine(550);
// PROTOTYPE //
// setTimeout(Function, Number);
///////////////
// Example
// 1.
setTimeout(
// first parameter
// (which is an anonymous function without parameter)
function () { alert("Bouuuuh"); },
// second parameter
3000
);
// MATHS //
// g() : is a Function
// f(g, x) : with x is a Number
///////////
// 2.
function test() {
alert("Bouuuuh");
};
setTimeout(test, 3000);
// Definition of Map function
function Map(arr, func) {
m_arr = [];
for (var i = 0; i < arr.length; ++i)
m_arr.push(func(arr[i]));
return m_arr;
}
// Definition of Filter function
function Filter(arr, func) {
f_arr = [];
for (var i = 0; i < arr.length; ++i)
if (func(arr[i]))
f_arr.push(arr[i]);
return f_arr;
}
/** EXAMPLES (with tasty juicy fruits) **/
var T = ["banana", "apple", "strawberry", "melon", "pineapple", "bob"];
console.log(T);
T = Filter(T, function (x) {
return x.indexOf("a") > - 1;
});
console.log(T);
T = Map(T, function (x) {
return x + x;
});
console.log(T);
T = Filter(T, function (x) {
return x.length > 15;
});
console.log(T);
T = Map(T, function (x) {
return x + "^^";
});
console.log(T);