JavaScript Calculator Program

ferzan saglam ferzans97 at gmail.com
Sat Dec 7 07:18:23 EST 2019


Hi People, I am working on a simple calculator which uses operands (+-*/).
The program allows me to choose an operand and enter the first two values, but when it gets to doing the maths, it gives me an error on 
"console.log ("The result is ", res);" under the + operand.
(error code reads: Println is not a function)

Any help will be much appreciated. 
Thanks in advance.

-----------------------------------------------------------

console.log ("1. Add numbers");	 	       	  	  	  	    	   	
console.log("2. Subtract numbers");	 	       	  	  	  	    	   	
console.log("3. Multiply numbers");	 	       	  	  	  	    	   	
console.log("4. Divide numbers");	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
console.log = prompt("What's your choice?");	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
var num1 = prompt("Enter the first number ");	 	       	  	  	  	    	   	
firstnumber = prompt;	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
var num2 = prompt("Enter the second number ");	 	       	  	  	  	    	   	
secondnumber = prompt;	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
var choice;	 	       	  	  	  	    	   	
var res;	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
if (choice == 1);	 	       	  	  	  	    	   	
    result = (num1 + num2);	 	       	  	  	  	    	   	
    console.log ("The result is ", res);	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
if (choice == 2);	 	       	  	  	  	    	   	
    result = (num1 - num2);	 	       	  	  	  	    	   	
    console.log ("The result is = ", res);	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
if (choice == 3);	 	       	  	  	  	    	   	
    result = (num1 * num2);	 	       	  	  	  	    	   	
    console.log ("The result is = ", res);	 	       	  	  	  	    	   	
	 	       	  	  	  	    	   	
if (choice == 4);	 	       	  	  	  	    	   	
    result = (num1 / num2);	 	       	  	  	  	    	   	
    console.log ("The result is = ", res);

-------------------------------------------------------------------


More information about the Python-list mailing list