On the problem of judging whether it is a digital error or not

topic description

write an expression that results in whether 2018 is a leap year.

related codes

function isLeapYear(year){
    if(typeof year != "number"){
        return console.log("");
    }else{
        if((year%4==0)&&(year%100!=0)||(year%400==0)){
            return console.log(year+"");
        }else{
            return console.log(year+"");
        }
    }
}
isLeapYear(asd);

what result do you expect? What is the error message actually seen?

according to my code, if the input is not a number, it will prompt "the input is not a number"
, but if you write asd directly in the value, it will report an error "ReferenceError: asd is not defined"
and add quotation marks. What is the reason? if you want to enter a value directly in it (without quotation marks), you will be prompted how to "enter a number instead of a number"

.
Feb.20,2022

  

prompts for input is not a number, haven't you already made a judgment in your function? The difference between asd without quotation marks and without quotation marks is as mentioned on the first floor.

Menu