function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min) + min); } function arrayRemove(arr, value) { return arr.filter(function(ele){ return ele != value; }); } // Define film list filmList = ['film1', 'film2', 'film3']; let randFilmIndex = getRandomInt(0, filmList.length); let randFilm = filmList[randFilmIndex]; filmList = arrayRemove(filmList, randFilm); document.getElementById('option1').innerHTML = randFilm;¿Por qué este código da el error?
Uncaught SyntaxError: Identifier 'randFilmIndex' has already been declared (at randomize-film.js:1:1)cuando lo ejecuto?
Estoy usando el espacio de trabajo de codecademy y mi html es
<!DOCTYPE html> <html> <head> <title>Rotten Tomatoes</title> <meta name="viewport" content="width=device-width,initial-scale=1" > <link href="style.css" rel="stylesheet"> <!-- Scripts --> <script src="scripts/randomize-film.js"></script> </head> <body> <center> <h1 class="title">Rotten Tomatoes Game</h1> <a href="rules.html"><h3>Click here to learn the rules</h3></a> <ul class="buttons"> <a href="you-picked-x-film.html"><li id="option1">Option 1</li></a> <a href="you-picked-x-film.html"><li id="option2">Option 2</li></a> </ul> </center> <script src="script.js"></script> </body> <!-- Scripts --> <script src="scripts/randomize-film.js"></script> </html>¿Me pueden ayudar a descubrir cuál es el problema? Estoy tratando de hacer un juego de tomates podridos.
Mi sistema operativo es Linux y el navegador es Chromium, pero eso no debería importar.
Eliminar el elemento de secuencia de comandos adicional
<script src="scripts/randomize-film.js"></script>