Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
JS - TP2 - API DOM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gwendal Margely
JS - TP2 - API DOM
Commits
4bb51850
Commit
4bb51850
authored
2 years ago
by
Gwendal Margely
Browse files
Options
Downloads
Patches
Plain Diff
12 o'clock push
parent
e6f2e7a7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.js
+8
-7
8 additions, 7 deletions
src/main.js
with
8 additions
and
7 deletions
src/main.js
+
8
−
7
View file @
4bb51850
...
...
@@ -3,7 +3,7 @@ const data = [
name
:
'
Mario Kart 8 Deluxe
'
,
released
:
'
2017-04-27
'
,
metacritic
:
92
,
background_image
:
'
images/mario-kart-8-deluxe.jpg
'
background_image
:
'
images/mario-kart-8-deluxe.jpg
'
,
},
{
name
:
'
God of War Ragnarok
'
,
...
...
@@ -15,7 +15,7 @@ const data = [
name
:
'
The Last of Us Part 2
'
,
released
:
'
2020-06-19
'
,
metacritic
:
94
,
background_image
:
'
images/the-last-of-us-part-2.jpg
'
background_image
:
'
images/the-last-of-us-part-2.jpg
'
,
},
];
function
renderGameThumbnail
({
name
,
background_image
,
released
,
metacritic
})
{
...
...
@@ -32,7 +32,7 @@ function renderGameThumbnail({name, background_image, released, metacritic}){
</a>`
;
}
let
html
=
''
;
data
.
forEach
(
name
=>
html
+=
renderGameThumbnail
(
name
)
);
data
.
forEach
(
name
=>
(
html
+=
renderGameThumbnail
(
name
)
)
);
/* avec la méthode reduce on aurait pu éviter de faire un `let` et gagner 1 ligne : */
// const html = data.reduce((str, game) => str + renderGameThumbnail(game), '');
document
.
querySelector
(
'
.gameList
'
).
innerHTML
=
html
;
...
...
@@ -196,4 +196,5 @@ on peut les comparer par ordre alphabétique avec localeCompare */
// const filteredData = data.filter(game => game.name.split('a').length === 3);
// const html = filteredData.reduce((str, game) => str + renderGameThumbnail(game), '');
// document.querySelector('.gameList').innerHTML = html;
const
magasinTitle
=
'
<h1>Magasin</h1>
'
;
document
.
querySelector
(
'
section.viewContainer header
'
).
innerHTML
=
magasinTitle
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment