Skip to content
GitLab
Projets
Groupes
Sujets
Extraits de code
/
Aide
Aide
Support
Forum de la communauté
Raccourcis clavier
?
Proposer une rétroaction
Contribuer à GitLab
Connexion
Activer/désactiver la navigation
Menu
Killian Deslandes
Exam-js
Comparer les révisions
main...91f88e78651f6136219faca43a41b62a7d2705aa
Commits (2)
prototype car et extra + generateImage
· 57ce5dc9
Killian Deslandes
a écrit
fév. 16, 2024
57ce5dc9
prototype dans le index.html
· 91f88e78
Killian Deslandes
a écrit
fév. 16, 2024
91f88e78
Masquer les modifications d'espaces
En ligne
Côte à côte
index.html
Voir le fichier @
91f88e78
...
@@ -32,12 +32,17 @@
...
@@ -32,12 +32,17 @@
</div>
</div>
<!-- include prototypes here -->
<!-- include prototypes here -->
<script
src=
"./js/extra.js"
></script>
<script
src=
"./js/car.js"
></script>
<script>
<script>
function
generateCar
(
image
,
make
,
model
,
description
,
price
,
category
,
year
,
mileage
,
extras
)
{
function
generateCar
(
image
,
make
,
model
,
description
,
price
,
category
,
year
,
mileage
,
extras
)
{
//Create an array of Extra instances based on Extras names and prices
//Create an array of Extra instances based on Extras names and prices
// Create a new Car instance
// Create a new Car instance
const
extraInstances
=
extras
.
map
(
extra
=>
new
Extra
(
extra
.
name
,
extra
.
price
));
return
new
Car
(
image
,
make
,
model
,
description
,
price
,
category
,
year
,
mileage
,
extraInstances
);
}
}
function
showHideExtra
(
btn
,
elt
,
car
)
{
function
showHideExtra
(
btn
,
elt
,
car
)
{
...
...
js/car.js
0 → 100644
Voir le fichier @
91f88e78
function
Car
(
image
,
make
,
model
,
description
,
price
,
category
,
year
,
mileage
,
extras
)
{
this
.
image
=
image
;
this
.
make
=
make
;
this
.
model
=
model
;
this
.
description
=
description
;
this
.
price
=
price
;
this
.
category
=
category
;
this
.
year
=
year
;
this
.
mileage
=
mileage
;
this
.
extras
=
extras
;
}
Car
.
prototype
.
generateImage
=
function
(
elt
)
{
const
img
=
document
.
createElement
(
'
img
'
);
img
.
src
=
this
.
image
;
img
.
alt
=
this
.
make
+
"
"
+
this
.
model
;
img
.
classList
.
add
(
'
card-img-top
'
);
elt
.
appendChild
(
img
);
};
\ No newline at end of file
js/extra.js
0 → 100644
Voir le fichier @
91f88e78
function
Extra
(
name
,
price
)
{
this
.
name
=
name
;
this
.
price
=
price
;
}
\ No newline at end of file