error handling - I can't seem to figure out how to fix two lints in my javascript. Can someone help me understand? -
i started javascript , made first game today! happy , in process of making lint free.
i'm getting frustrated, fixed mistakes(lints) there 2 can't seem fix! i've been trying on hour. please me solve this? i'm getting frustrated :(
the lints are:
5 'prompt' used before defined. var name = prompt("hallo speler, wat uw naam?.", "naam van speler");
5 expected identifier , instead saw '"'. var name = prompt("hallo speler, wat uw naam?.", "naam van speler");
this javascript code:
//schrijft functie begin spel. value van de input wordt een string. opnieuw knop wordt disabled. var name = prompt("hallo speler, wat uw naam?.", "naam van speler"); var data = [ [0, 11, "een hele goede morgen,"], [12, 17, "goede middag,"], [18, 24, "goede avond"] ], hr = new date().gethours(); (var = 0; < data.length; i++) { if (hr >= data[i][0] && hr <= data[i][1]) { document.getelementbyid('welkom').innerhtml = data[i][2] + " " + name; } } function beginspel() { document.getelementbyid("input_txt").value = ""; document.getelementbyid("input_txt").focus(); document.getelementbyid("input_txt").disabled = false; document.getelementbyid("guess_btn").disabled = false; document.getelementbyid("playagain_btn").disabled = true; //tekst weergeeft op het begin informatie on wat je moet doen. document.getelementbyid("message_txt").innerhtml = "kies een nummer tussen 1 en 100."; //nummer van de computer wordt berekend. randomnumber = math.ceil(math.random() * 100); //variabele input de tekst van input_txt input = document.getelementbyid("input_txt"); var clicks = 0; // sets global variable // when window loads document.getelementbyid("guess_btn").addeventlistener("click", function() { //the above creates event listener tell //script when clicks on element //with id "button" clicks++; // adds 1 variable clicks document.getelementbyid('aantalklik').innerhtml = "u heeft " + clicks + " keer geraden!"; // displays clicks popup }) } var guess_btn = document.getelementbyid('guess_btn'); guess_btn.addeventlistener('click', guessnumber); var playagain_btn = document.getelementbyid('playagain_btn'); playagain_btn.addeventlistener('click', beginspel); function guessnumber() { guess = document.getelementbyid("input_txt").value; document.getelementbyid("input_txt").focus(); if (guess === "") { document.getelementbyid("message_txt").innerhtml = "0 te laag. probeer opnieuw!"; } else if (guess > randomnumber) { document.getelementbyid("message_txt").innerhtml = guess + " te hoog. probeer opnieuw!"; input_txt.value = ""; } else if (guess < randomnumber) { document.getelementbyid("message_txt").innerhtml = guess + " te laag. probeer opnieuw!" input_txt.value = ""; } else { document.getelementbyid("message_txt").innerhtml = "je hebt goed geraden! het nummer " + guess + "."; input_txt.value = ""; endgame(); } } function endgame() { document.getelementbyid("input_txt").disabled = true; document.getelementbyid("guess_btn").disabled = true; document.getelementbyid("playagain_btn").disabled = false; } window.onload = beginspel;
thanks lot taking time helping me.
xx
the first error because not know prompt
defined. can prefix window
this: window.prompt(...
or add prompt
list of "globals" passed in jshint configuration: http://jshint.com/docs/