Sha256: d42a94ace9d2aca72129f8d6b3cf5796d0a3e0f098905fb57e7fe80775f2ca53

Contents?: true

Size: 911 Bytes

Versions: 10

Compression:

Stored size: 911 Bytes

Contents

===WScript===
{{works with|JScript}}
{{works with|SpiderMonkey}}
Note that the operators work the same in all versions of JavaScript; the requirement for specific implementations is in order to get user input.
var a = parseInt(get_input("Enter an integer"), 10);
var b = parseInt(get_input("Enter an integer"), 10);

WScript.Echo("a = " + a);
WScript.Echo("b = " + b);
WScript.Echo("sum: a + b = "        + (a + b));
WScript.Echo("difference: a - b = " + (a - b));
WScript.Echo("product: a * b = "    + (a * b));
WScript.Echo("quotient: a / b = "   + (a / b | 0)); // "| 0" casts it to an integer
WScript.Echo("remainder: a % b = "  + (a % b));

function get_input(prompt) {
    output(prompt);
    try {
        return WScript.StdIn.readLine();
    } catch(e) {
        return readline();
    }
}
function output(prompt) {
    try {
        WScript.Echo(prompt);
    } catch(e) {
        print(prompt);
    }
}

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/javascript.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/javascript.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/javascript.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/javascript.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/javascript.txt