Objective
- Show four random golf courses out of the total list of roughly 100 courses in the array if
content.featured == "featured. - The key data that needs to switch are , which is the name of the golf course and the hyphenated slug name .
I've tried using the random filter from this StackOverflow question, but I only seem to be getting the first letter of the course name. Without the filter, I just get the first four courses in the array.
index.html
<div class="explore__courses">
</div> <!-- .explore__courses -->
Sample course data
var locations = [
{
"name": "Aberdeen",
"slug": "aberdeen",
"lat": "38.533695",
"lng": "-90.619151",
"address": "4111 Crescent Rd, Eureka, MO 63025",
"state": "MO",
"holes": "18"
},
{
"name": "Acorns",
"slug": "acorns",
"lat": "38.294035",
"lng": "-90.199375",
"address": "3933 Ahne Rd, Waterloo, IL 62298",
"state": "IL",
"holes": "18"
},
{
"name": "American Legion",
"slug": "american-legion",
"lat": "38.803961",
"lng": "-89.965593",
"address": "58 IL-157, Edwardsville, IL 62025",
"state": "IL",
"holes": "9 "
},
{
"name": "Annbriar",
"slug": "annbriar",
"lat": "38.349734",
"lng": "-90.203934",
"address": "1524 Birdie Ln, Waterloo, IL 62298",
"state": "IL",
"holes": "18"
},
{
"name": "Arlington",
"slug": "arlington",
"lat": "38.7079279",
"lng": "-90.0379311",
"address": "200 Arlington Dr, Granite City, IL 62040",
"state": "IL",
"holes": "18"
},
{
"name": "Ballwin",
"slug": "ballwin",
"lat": "38.605788",
"lng": "-90.538963",
"address": "333 Holloway Rd, Ballwin, MO 63011",
"state": "MO",
"holes": "9 "
},
{
"name": "Bear Creek",
"slug": "bear-creek",
"lat": "38.817943",
"lng": "-90.896974",
"address": "158 Bear Creek Dr, Wentzville, MO 63385",
"state": "MO",
"holes": "18"
},
{
"name": "Bear Creek Valley ",
"slug": "bear-creek-valley",
"lat": "38.153609",
"lng": "-92.600756",
"address": "910 MO-42, Osage Beach, MO 65065",
"state": "MO",
"holes": "18"
},
];
Aucun commentaire:
Enregistrer un commentaire