The code goes like this. It a function which takes in two parameters 'a' and 'b' and compares them both and alerts the output. But this isn't working for me!
<script type=”text/javascript”>
function compare(a, b) {
if (a < b) {
alert(“A is less than B”);
} else if (a > b) {
alert(“A is greater than B”);
} else {
alert(“A is equal to B”);
}
}
</script>
JsFiddle Link : http://jsfiddle.net/tTCG6/2/
Could someone please help me with it?
You are using smart quotes ( “ ”
), which Javascript will not recognize. Use normal quotes ( " "
) instead.
The smart quotes may be because you are using a text editor that does this automatically. You should use a plaintext editor (like Notepad for Windows or TextEdit for a Mac), or use an IDE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.