Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 545 Bytes

File metadata and controls

24 lines (15 loc) · 545 Bytes

有時候我們需要把一個數字轉換成字串。

這時,你可以使用 .toString() 方法。例如:

var n = 256;
n = n.toString();

挑戰:

建立一個名為 number-to-string.js 的檔案。

在該檔案中定義一個名為 n 的變數,並賦值 128;

在變數 n 上呼叫 .toString() 方法。

使用 console.log() 將 .toString() 方法的結果輸出到終端機上。

執行下面的命令來檢查你撰寫的程式是否正確:

javascripting verify number-to-string.js