I'm creating a script in Google Optimize for a travel website. The idea is to return random strings from an array in order to display a tip in the search bar, e.g. "Try searching for [location]". However, there are two search bars; if you click on the first one it unfolds and a second one appears.
Right now, the same line is displayed in both search bars.
Rather than one array that contains both the destinations and hotel names I would like to create two arrays, one with the destinations and one with the hotel names. Is there a way to link each string to another one from a different array, for example by giving them values.
Try searching for Spain and then in the second search bar try [Spanish hotel].
$(".vak-field__cover:first").on("click", function(){
var texts = ["Egypt", "Spain", "Creta", "France", "Fuerteventura", "Bali", "Sicily",
"Turkish Riviera", "Mallorca", "Gran Canaria", "Mirador Maspalomas",
"Vila Sal Azul", "Millor paradiso playa", "Cinc plats *3",
"Portobello village", "Main star park 5*", "Sam's treasure trove"] ;
var randomNumber = Math.floor(Math.random() * 17);
console.log(randomNumber);
$( ".vak-quicksearch__placeholder:first" ).html( "You could search for \"" + texts[randomNumber] + "\"" );
$( ".vak-field>input" ).attr( "placeholder", "Try \"" + texts[randomNumber] + "\"" );
});
