Skip to content

Category: Questions

JavaScript getting txt file info not working, no errors

I’m using the code bellow to store everything in a text file into a JavaScript var which than will go into a html id and it will be displayed. but the output id will show nothing in html. Can anyone help me with this please? Answer window.onload doesn’t wait for the AJAX to complete. You should pu…

Convert 2D JS array to json string

My array in variable is: I’ve mentioned key and value here for the 2D array, I’m trying to convert this to JSON string. I tried JSON.stringify(arraydata), arraydata is the variable where the array is stored, but it makes the string empty, whereas array data is correct. Edit: This is how I’m …

Trying to validate email endings in javascript

Question: I am trying to validate email endings in an array I can get this to work when validEndings is just a singular string e.g let validEndings = ‘@gmail.com’ but not when its in an array comparing multiple things Answer You can solve the problem with regex. Example: