0
Why is my typeof detection code not working?
2 Answers
+ 5
Write your if condition like this
typeof(num)== 'number'
+ 4
try this code
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>var num="randomtedt";
if (typeof(num) == "number"){
alert("c un nombre") ;
} else {
alert("pas un nombre") ;
}</script>
</body>
</html>
differences are
== instead of =
"number" instead of number
== compare opertation
number is a string not a variable