All programming languages support the basic arithmetic operations of addition, subtraction, multiplication and division of numbers. The addition operator is also used to add, or concatentate, two strings together.
Combining different values with addition
// Add numbers, add strings, // and add variables // containing numbers. write(3+5); write("3"+"5"); var x=3; var y=5; write(x+y);
value1 + value2;
Name | Type | Required? | Description |
---|---|---|---|
value1 | Any | First value to be added or concatenated | |
value2 | Any | Second value to be added or concatenated |
The sum of two numbers or concatenation of two strings
Found a bug in the documentation? Let us know at documentation@code.org