0

I've tried to solve my problem with the help of multiple teachers at my school, but I was told they don't know what has caused the problem was and I should try fixing it by trial and error. Also I've tried several JavaScript Error checkers on other sites, which gave me good feedback/warnings of what I was doing wrong and how I could improve my JavaScript, but didn't solve my problem.

My problem

In my HTML my script element doesn't find my script.js. Because I have multiple tasks at school to complete, I copy and paste my files and modify the copied ones. and in all other files this code worked well, until this one.

HTML > index.html

<!doctype HTML>
<html lang=nl>
    <head>
        <title> JS lab </title> 
        <meta charset=utf-8>
        <meta name="description" content="Javascript">
        <meta name="author" content="Niels Langeweg">
        <!-- <link rel="stylesheet" href="style.css"> -->
    </head>
    <body>

        <script type="text/javascript" src="script.js">
            // using script.js
            //document.writeln("current day is " + currentDay() );
            useMe();
        </script>

    </body>
</html>

JavaScript > script.js

// script.js
function currentDayNumber(){
    var date = new Date();
    return(date.getDay());

}

function day( value ) {
    var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    return (days[value]);
}

function currentDay() {
    return day(currentDayNumber()); 
}


function randomLession () {

    var value = new Array();
    value = ["English", "Science", "Mathematics", "Latin", "IT", "Spanish"];
}

function getSchedule () {
    var schedule = new Array();
    for (var i = 0; i < 7; i++){
        schedule[i] = new Array();
        for(var u = 0; u < 8; u++){
            schedule[i][u] = "";
        }
    }
}

Folder

myTask -> index.html
       -> script.js
George
  • 6,630
  • 2
  • 29
  • 36
Niels
  • 13
  • 7
  • 2
    You can't use the `src` attribute and inline code together (It will only run/execute one, the inline I think) https://stackoverflow.com/questions/1056325/javascript-inline-script-with-src-attribute – George Nov 15 '17 at 10:49
  • Try removing everything inbetween the script tags, does it work then? – Bojan Ivanac Nov 15 '17 at 10:49
  • Since you already have the answer, just split the code up in two script-tags, I'm wondering how this worked in your other projects? :) – xander Nov 15 '17 at 10:53

0 Answers0