JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="textfromuser" value="123"/>

JavaScript

function validate(){
  // empty array
  var ar = [];
  // obtain a string from the input "text" field, retrieved by the "id" attribute
  var VAlidation = document.getElementById("textfromuser").value;
  // split the string into a character array
  var lists = VAlidation.split('');
  // iterate over the character array
  for(var i=0; i<lists.length; i++){
    // create a string concatenating the array's element and '.jpg'
    var str = lists[i]+'.jpg';
    // add the string var to the array
    ar.push(str);
  }
  return ar;
}
// having two arrays
var list = validate();
var list2 = ['1.jpg','2.jpg','3.jpg'];
// "Serialize" the arrays, the join() method 
/// joins the elements of an array into a string, and returns the string
serlist = list.join();
serlist2 = list2.join();
// Compare both serialized arrays
if(serlist==serlist2){
 alert("Arrays are equal "+serlist);
}  
else{
 alert("Arrays are not equal "+serlist+" - "+serlist2);
}