1 year ago

#377444

test-img

Younes Meridji

javascript function and logical statement

i have wrote a code of HTML, but the JavaScript function is not called and i have an error message in the console: "myfunction is not a function"

<!DOCTYPE html>
<html>
<head></head>
<body>
    <input type="text" id="mydata"> 
</body>

<script>    
    document.getElementById('mydata').addEventListener("change", myfunction);
    if(typeof mydata.value === 'string' && mydata.value.length === 0){
        console.log('outside function');
    }   
    else{
        function myfunction() {
            console.log('inside function');         
        }
    }               
</script>
</html>

javascript

html

function

logical-operators

0 Answers

Your Answer

Accepted video resources