How to use Relative File Path instead of Absolute File Path in Arrays

How can I replace the images we used in our lesson to my own choice of images. I tried uploading my choices of photo using TechSmith capture and grabbed the link but it still won’t work.
This is the code we had on our lesson:

var cardsArray = [
{ ‘name’: ‘CSS’, ‘img’: ‘’, },
{ ‘name’: ‘HTML’, ‘img’: ‘’, },
and so on …

I tried doing this line of code:

var imgArray = new Array();
imgArray[0] = new Image();
imgArray[0].src = ‘images/img/Splash_image1.jpg’;

So I can use relative file path but It creates another problem of losing the name attribute per picture.

Is there a way I can modify the first code?
I’m stuck with our lesson and can’t move on. I’m confused.

Hey there,

please use the Get Help button in a lesson to create a forum topic and fill in the questions.


We currently don’t know what our lesson means. :slightly_smiling_face:

1 Like

Okay sorry. Can I know if there’s a way I can get images on the same folder and not with an url link?

Here’s the code: