Codecademy -> Learn JavaScript (序) 筆記 === ###### tags: `JavaScript` `js` 由於學習習慣,學習後還是想多練習一下,稍微 Google 了一下,發現蠻多大大推薦這個教學平台 [Codecademy: Learn to Code - for Free](https://www.codecademy.com/) 可以讓我多做一些練習,這邊習慣性的記錄學習的歷程,還能幫助學習記憶與整理學習內容。 --- ## 註冊 首先,先輸入信箱與密碼,晚點就會收到驗證信件。  輸入一下帳號密碼,註冊就成功了。 --- ## 熱身  進入 Codecademy 會有一個熱身的練習,只要照著左邊的說明,就能順利的把 課程完成,順便熟悉一下操作。 --- ## 開始練習 JavaScript  點擊「Learn JavaScript」進入教學首頁。  按下「Start」開始練習。  總共有10關。 --- ### 第 1 關 介紹 JavaScript 介紹一下 JavaScript,有興趣可以看一下左邊的說明,沒興趣直接按下黃色「Next」進行下一關。 --- ### 第 2 關 Console  練習一下 console.log() 的使用方法。 這關總共有兩項要求,寫好程式碼,按下中間下方「Run」按鈕,達成左邊會有 checkbox 由灰色變成青色並打勾。 中間輸入 console.log() 指令。 ```javascript= console.log(43); console.log(3); ``` 右邊則是輸出視窗,會列出 console.log() 內的內容。  特別要注意的是第二項要輸入一週學習天數,如果忘記了,你可以在右上角 Account Settings 看到先前的設定資訊。 --- ### 第 3 關 Comments (註解)  註解有單行註解與多行註解 ```javascript= // opening line console.log('It was love at first sight.'); /* console.log('The first time Yossarian saw the chaplain he fell madly in love with him.'); console.log('Yossarian was in the hospital with a pain in his liver that fell just short of being jaundice.'); console.log('The doctors were puzzled by the fact that it wasn\'t quite jaundice.'); console.log('If it became jaundice they could treat it.'); console.log('If it didn\'t become jaundice and went away they could discharge him.'); console.log('But this just being short of jaundice all the time confused them.'); */ ``` --- ### 第 4 關 Data Types (資料型態)  這關左邊說明看一下,都是一些觀念說明。 主要有下面這幾種: * Number (數字) * String (字串) * Boolean (布林) * Null * Undefined * Symbol * Object ```javascript= console.log('JavaScript'); console.log(2011); console.log('Woohoo! I love to code! #codecademy'); console.log(20.49); ``` --- ### 第 5 關 Arithmetic Operators (算數運算子) 1. Add: + 2. Subtract: - 3. Multiply: * 4. Divide: / 5. Remainder: % 利用 console.log() 做加減乘除的問題。  ```javascript= console.log(43+3.5); console.log(2020-1969); console.log(65/240); console.log(0.2708*100); ``` --- ### 第 6 關 String Concatenation (字串組合) 利用 console.log() 做字串組合。  ```javascript= console.log('Hello'+'World'); console.log('Hello'+' '+'World'); ``` --- ### 第 7 關 Properties (屬性) 利用「屬性」,來查詢字串的長度。  ```javascript= console.log('Teaching the world how to code'.length); ``` --- ### 第 8 關 Methods (方法) 利用「方法」,來做英文字轉大寫與刪除空白字串。  ```javascript= // Use .toUpperCase() to log 'Codecademy' in all uppercase letters console.log('Codecademy'.toUpperCase()); // Use a string method to log the following string without whitespace at the beginning and end of it. console.log(' Remove whitespace '.trim()); ``` --- ### 第 9 關 Built-in Objects (內建物件) 這邊會運用到內建物件的一些功能,所以還要練習一下,如何從說明文件上,找到我們須要的功能。  產生 0 - 100 的隨機變數。 ```javascript= console.log(Math.random() * 100); ``` 利用現有變數,捨去小數點。 ```javascript= console.log(Math.floor(Math.random() * 100)); ``` 利用左邊提示的超連結,找 Math 中取最小且大於的正整數(Math.ceil(x))。 ```javascript= console.log(Math.floor(Math.random() * 100)); console.log(Math.ceil(43.8)); ``` 利用左邊提示的超連結,找 Number 中判斷是否為整數。 ```javascript= console.log(Math.floor(Math.random() * 100)); console.log(Math.ceil(43.8)); console.log(Number.isInteger(2017)); ``` --- ### 第 10 關 Review  這關是觀念說明,按下黃色「UpNext」按鈕繼續下一關。 --- ## [Learn JavaScript variables (變數)](https://hackmd.io/@chiisen/HJOkcJ9TL) ## 參考資料 [Codecademy 線上任務關卡學習平台,學會各種網頁語言(JavaScript、jQuery、PHP、Python、HTML/CSS、Ruby)](https://www.minwt.com/webdesign-dev/html/17859.html)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.