An Input/Output Script that attempts to average two numbers.
There is a fairly subtle reason why this script doesn't work properly.
There are two things that contribute.
-
A prompt window always returns a string, even if you enter a number.
That makes sense since the job of a prompt window is to grab the characters you type on the keyboard.
If you type numeric keys, it just records the characters. It doesn't care about the nature of the characters you type.
-
The concatenation operator has a dual role. It will add numbers, but will concatenate strings.
Fortunately, there is an easy fix as the next example shows.