Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fini #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions filter-map/ex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Sortie attendue:
*/

function getJedisNames(characters) {
let padawan = characters.filter(char => char.side === 'light')
return padawan.map(jedi => {return jedi.name})

}

module.exports = getJedisNames;
5 changes: 5 additions & 0 deletions filter-map/ex2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Sortie attendue:
*/

function getCampusesTeachingReact(campuses) {

let best = campuses.filter(lang => lang.curriculums.includes('JS/React') === true)
return best.map(sch => {return sch.city})


}

module.exports = getCampusesTeachingReact;
1 change: 1 addition & 0 deletions filter/ex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Sortie attendue:
*/

function getPositiveNumbers(numbers) {
return numbers.filter(numbers => numbers >= 0)
}

// Si besoin, tu peux toujours visualiser le résultat avec console.log,
Expand Down
3 changes: 2 additions & 1 deletion filter/ex2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Exemple d'entrée:
*/

function getMultiplesOf(numbers, n) {
}
return numbers.filter(numbers => (numbers % n === 0 )
)}

// Ne pas modifier l'export
module.exports = getMultiplesOf;
4 changes: 3 additions & 1 deletion filter/ex3.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Sortie attendue:
*/

function keepStarks(names) {
}
return names.filter(names => names.endsWith('Stark')

)}

// Ne pas modifier l'export
module.exports = keepStarks;
4 changes: 4 additions & 0 deletions filter/ex4.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Sortie attendue:
*/

function filterOnPrice(products, maxPrice) {

return products.filter(price => price.price <= maxPrice)


}

// Ne pas modifier l'export
Expand Down
1 change: 1 addition & 0 deletions filter/ex5.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Exemple d'entrée:
*/

function searchWordFilter(items, search) {
return items.filter(cola => cola.toLowerCase().includes(search.toLowerCase()) === true)
}

// Ne pas modifier l'export
Expand Down
5 changes: 5 additions & 0 deletions filter/ex6.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Sortie attendue:
*/

function filterOffensiveComments(comments, bannedWords) {
for (let i = 0; i<bannedWords.length; i++){
const carotte = comments.filter(comment => comment.toLowerCase().includes(bannedWords[i]) === false)
comments = carotte
}
return comments
}

// Ne pas modifier l'export
Expand Down
18 changes: 18 additions & 0 deletions map/ex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,29 @@ En sortie: [
*/

function getStringsLength(strings) {
return strings.map(function(aliment){
return aliment + ' contains ' + aliment.length + ' characters';

});


}












// Si besoin, tu peux toujours visualiser le résultat avec console.log,
// mais alors, il faut alors lancer l'exercice avec node map/ex1
// console.log(getStringsLength(['Cat', 'Lion', 'Tiger', 'Jaguar', 'Leopard']));

// Ne pas modifier l'export

module.exports = getStringsLength;
11 changes: 11 additions & 0 deletions map/ex2.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ En sortie: [
*/

function getFoodCategories(foods) {
return foods.map(aliment => {
if (aliment.isVegetarian === true){
return (aliment.food + ' is suitable for vegetarians')

} else {
return (aliment.food + ' is not suitable for vegetarians')
}



})
}


Expand Down
10 changes: 10 additions & 0 deletions map/ex3.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ En sortie:
*/

function getMoviesFreshness(movies) {
return movies.map(movie => {
if (movie.rating < 60){
movie.label = 'rotten'
} else if (movie.rating >= 60 && movie.rating <= 75){
movie.label = 'fresh'
} else {
movie.label = 'certified fresh'
}
return movie
})
}


Expand Down
8 changes: 8 additions & 0 deletions map/ex4.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ Tableau de sortie correspondant (toFixed transforme les nombres en chaînes)
*/

function getCirclesProperties(radiuses) {
return radiuses.map(obj => {
const tamer = new Object()
tamer.radius = obj;
tamer.circumference = (2 * Math.PI * obj).toFixed(3);
tamer.surface = (Math.PI * obj * obj).toFixed(3);

return tamer
})
}


Expand Down
15 changes: 15 additions & 0 deletions map/ex5.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ Tableau renvoyé par multiplyOddIndices:
*/

function multiplyOddIndices(numbers) {

return numbers.map( number => {

if (numbers.indexOf(number) % 2 === 0) {
return number
// nbre pair
} else {
return (numbers.indexOf(number) * number)
// nbre impair
}


})

}


module.exports = multiplyOddIndices;
2 changes: 1 addition & 1 deletion tests/filter-map1.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getJedisNames = require('../filter-map/ex1.js');

xdescribe('map + filter - exercice 1', () => {
describe('map + filter - exercice 1', () => {

test('getJedisNames', () => {
expect(getJedisNames([
Expand Down
2 changes: 1 addition & 1 deletion tests/filter-map2.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getCampusesTeachingReact = require('../filter-map/ex2.js');

xdescribe('map + filter - exercice 2', () => {
describe('map + filter - exercice 2', () => {

test('getCampusesTeachingReact', () => {
expect(getCampusesTeachingReact([
Expand Down
2 changes: 1 addition & 1 deletion tests/filter-map3.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getStudentsPerCurriculum = require('../filter-map/ex3.js');

xdescribe('map + filter - exercice 3', () => {
describe('map + filter - exercice 3', () => {

test('getStudentsPerCurriculum', () => {
expect(getStudentsPerCurriculum(
Expand Down
2 changes: 1 addition & 1 deletion tests/filter-map4.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getActivitiesMembers = require('../filter-map/ex4.js');

xdescribe('map + filter - exercice 4', () => {
describe('map + filter - exercice 4', () => {

test('getActivitiesMembers', () => {
expect(getActivitiesMembers(
Expand Down
2 changes: 1 addition & 1 deletion tests/filter1.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getPositiveNumbers = require('../filter/ex1.js');

xdescribe('filter - exercice 1', () => {
describe('filter - exercice 1', () => {

test('getPositiveNumbers', () => {
expect(getPositiveNumbers([7, -4, 2, 0, -10, 3, 11]))
Expand Down
2 changes: 1 addition & 1 deletion tests/filter2.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getMultiplesOf = require('../filter/ex2.js');

xdescribe('filter - exercice 2', () => {
describe('filter - exercice 2', () => {

test('getMultiplesOf', () => {
expect(getMultiplesOf([-12, -10, -7, -1, 5, 8, 11, 15, 20, 27], 5))
Expand Down
2 changes: 1 addition & 1 deletion tests/filter3.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const keepStarks = require('../filter/ex3.js');

xdescribe('filter - exercice 3', () => {
describe('filter - exercice 3', () => {

test('keepStarks', () => {
expect(keepStarks([
Expand Down
2 changes: 1 addition & 1 deletion tests/filter4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const products = [
}
];

xdescribe('filter - exercice 4', () => {
describe('filter - exercice 4', () => {

test('filterOnPrice (price <= 500)', () => {
expect(filterOnPrice(products, 500))
Expand Down
2 changes: 1 addition & 1 deletion tests/filter5.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const searchWordFilter = require('../filter/ex5.js');

xdescribe('filter - exercice 5', () => {
describe('filter - exercice 5', () => {

test('searchWordFilter', () => {
expect(searchWordFilter([
Expand Down
2 changes: 1 addition & 1 deletion tests/filter6.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const filterOffensiveComments = require('../filter/ex6.js');

xdescribe('filter - exercice 6', () => {
describe('filter - exercice 6', () => {

test('filterOffensiveComments', () => {
expect(filterOffensiveComments([
Expand Down
2 changes: 1 addition & 1 deletion tests/map1.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getStringsLength = require('../map/ex1.js');

xdescribe('map - exercice 1', () => {
describe('map - exercice 1', () => {

test('getStringsLength', () => {
expect(getStringsLength([
Expand Down
2 changes: 1 addition & 1 deletion tests/map2.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getFoodCategories = require('../map/ex2.js');

xdescribe('map - exercice 2', () => {
describe('map - exercice 2', () => {

test('getFoodCategories', () => {
expect(getFoodCategories( [
Expand Down
2 changes: 1 addition & 1 deletion tests/map3.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getMoviesFreshness = require('../map/ex3.js');

xdescribe('map - exercice 3', () => {
describe('map - exercice 3', () => {

test('getMoviesFreshness', () => {
expect(getMoviesFreshness(
Expand Down
2 changes: 1 addition & 1 deletion tests/map4.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const getCirclesProperties = require('../map/ex4.js');

xdescribe('map - exercice 4', () => {
describe('map - exercice 4', () => {

test('getCirclesProperties', () => {
expect(getCirclesProperties( [
Expand Down
2 changes: 1 addition & 1 deletion tests/map5.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const multiplyOddIndices = require('../map/ex5.js');

xdescribe('map - exercice 5', () => {
describe('map - exercice 5', () => {

test('multiplyOddIndices', () => {
expect(multiplyOddIndices([3, 8, 11, 13, 19, 7]))
Expand Down