I see
1. form inputs but no form
2. use of variables that are not defined
3. missing attributes on elements like name and value tags
4. script in the body not the head... generally speaking, code, unless for some reason for it, code should be placed within the head tag.
5. the error I get upon looking closer, I see the use of a character that is not a single quote, the main reason for using the " double quotes in a string is its not missed like a ' single quote or mistaken like this ‘ ’ as single quotes.
6. Remember DRY in all code, DRY = Dont Repeat Yourself, you have the possible use of a function to do repeated types of calculation...
function temp( scale , temp ){
try{
switch( scale.toLowerCase() ){
case "c2f":
return ( 9 / 5 ) * temp + 32;
break;
case "f2c":
return ( temp - 32 ) / ( 9 / 5 );
break;
default:
return temp;
}
}catch(e){ console.log("Error message: \r\n\t%s",e); }
}
function convert( el ){
...
... other code here
...
case "x":
answer.value = temp( "c2f", el.value ) .toFixed(2);
break;
case "y":
answer.value = temp( "f2c", el.value ) .toFixed(2);
break;
}
}
The try..catch clause is to prevent divide by zero errors from happening.
and you could put in the missing bits... Its tidy code then
<input name="c" id="c" onkeyup="convert(this,f)" size="8" value="">
I tested the temperature with -17.7777777777777 deg C and got 0 deg F. which is close enough I think.
So from this you should be able to update your code and correct the errors in the switch..case block.