prompt 彈出視窗並有input欄位
Code:
1.
( )
: control order of operations2.
*
and /
: multiplication and division3.
-
and +
: subtraction and additionmodulo%
23 % 10 = 2
Substring:
"some word".substring(x, y)
where x
is where you start chopping and y
is where you finish chopping the original string.
The number part is a little strange. To select for the "he" in "hello", you would write this:
"hello". substring(0, 2);
Each character in a string is numbered starting from 0, like this:
0 1 2 3 4
| | | | |
h e l l o
The letter
h
is in position 0
, the letter e
is in position 1
, and so on.
Therefore if you start at position
console.log("January".substring(0,3));
console.log("Melbourne is great".substring(0,12));
console.log("Hamburgers".substring(3,10));
Jan
Melbourne is
burgers
0
, and slice right up till position 2
, you are left with just he
ex:第4個字到第7個字
"put some string".substring(3,7);
ex:
console.log("January".substring(0,3));
console.log("Melbourne is great".substring(0,12));
console.log("Hamburgers".substring(3,10));
Jan
Melbourne is
burgers