Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Append image from array to HTML

I'm trying make buttons to append images to HTML from array. Why the first snippet doesn't work?

First snippet with array doesn't work

const fs = require('fs');
const dir = fs.readdirSync('/Files/Изображение').filter(files => files.endsWith('.png'))

let imag = dir[0];

function createImgBlock() {
    const imgBlocks = document.createElement('img');
    imgBlocks.src = '/Files/Изображение/' + dir[0];
    document.body.append(imgBlocks);
}

Second snippet only with the name of image is work

const fs = require('fs');
const dir = fs.readdirSync('/Files/Изображение').filter(files => files.endsWith('.png'))

let imag = dir[0];

function createImgBlock() {
    const imgBlocks = document.createElement('img');
    imgBlocks.src = '/Files/Изображение/' + '1407916_900_600.png';
    document.body.append(imgBlocks);
}

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!