This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** intermediate algorithm challenge n° 4 : | |
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou | |
***/ | |
function whatIsInAName(collection, source) { | |
const srcKeys = Object.keys(source) | |
return collection.filter((obj) => { | |
return srcKeys.every((key) => { | |
return obj.hasOwnProperty(key) && obj[key] === source[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bubble sort | |
const bubbleSort = (numbersArray) => { | |
const arrayLenght = numbersArray.length; | |
for (let i = 0; i < arrayLenght; i++) { | |
for (let j = 0; j < arrayLenght; j++) { | |
if (numbersArray[j] > numbersArray[j +1]) { | |
const currentNumber = numbersArray[j] | |
numbersArray[j] = numbersArray[j +1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** intermediate algorithm challenge n° 4 : | |
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou | |
***/ | |
function whatIsInAName(collection, source) { | |
const srcKeys = Object.keys(source) | |
return collection.filter((obj) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MY_NAME=Bob | |
MY_CITY=Laillé | |
MY_LANGUAGE=React |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request'); | |
request('https://swapi.co/api/people/1/', function (error, response, body) { | |
const obj = JSON.parse(body); | |
console.log(obj); | |
request(obj.films[0], function (err, res, bod) { | |
const movie = JSON.parse(bod); | |
console.log(movie.title); // result => "The Empire Strick Back" | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> select name, count(*) AS nb_student | |
-> from player | |
-> JOIN wizard ON wizard.id=player.wizard_id | |
-> JOIN team ON team.id=player.team_id | |
-> GROUP BY team_id | |
-> ORDER BY nb_student DESC; | |
+------------+------------+ | |
| name | nb_student | | |
+------------+------------+ | |
| Gryffindor | 36 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> select firstname, lastname, role, name | |
-> from player | |
-> JOIN wizard ON wizard.id=player.wizard_id | |
-> JOIN team ON team.id=player.team_id | |
-> ORDER BY name ASC, role ASC, lastname ASC, firstname ASC; | |
+-------------+-----------------+--------+------------+ | |
| firstname | lastname | role | name | | |
+-------------+-----------------+--------+------------+ | |
| Sirius | Black | beater | Gryffindor | | |
| Lavender | Brown | beater | Gryffindor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
// ------- QUETE EXPRESS 3 ---------- | |
const bodyParser = require('body-parser'); | |
// Support JSON-encoded bodies | |
app.use(bodyParser.json()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
const bodyParser = require('body-parser'); | |
// Support JSON-encoded bodies | |
app.use(bodyParser.json()); | |
// Support URL-encoded bodies | |
app.use(bodyParser.urlencoded({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
connection.connect(function (err) { | |
if (err) { | |
return console.error('error: ' + err.message); | |
} |
NewerOlder