Adding string values into php/javascript

Chimini

Hello I have some code that I need to insert some string values into but everytime I put in letters the script wont work.

<script type="text/javascript">
"use strict";
var values = [1,2,3,4,5,6,7,8,9]; /*add string values here*/

var rand = function(){
var arr = values;
var x = Math.floor((Math.random() * arr.length));
var index = arr.indexOf(arr[x]);
document.getElementById('random').value = arr[x];

if(index > -1){
arr.splice(index,1);
}
if(arr.length<1){
document.getElementById('random').value = "no more options left";
}
console.log(arr);
}
</script>

I need to add string values to where I have 'add string values here' in my comments. So I can have:

var values = [H0A0,H0A1,H0A3,H0A4,H0A5+,H1A0];

As an example. Many thanks ahead. Also I am very new to JS/PHP.

Jesper

Here you go

var values = ['H0A0','H0A1','H0A3','H0A4','H0A5+','H1A0'];

If you wanna insert strings into an array you will always have to write en strings inside single quotes (') or double quotes (")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related