For my learning tools, I’ve chosen both Codecademy and Lynda.com. Codecademy served me very well when I was first learning HTML, so this is my service of choice.
The first function we are taught is a simple text to screen command.
This will display simply the word ‘Hello!’.
Next up are some key terms:
- Strings – Any grouping of Keyboard characters (Letters, Spaces, Numbers or Symbols) surrounded by single quotes (‘) or double quotes (“).
- Numbers – Any number, including numbers with decimals: e.g. 4, 1516, .002, 23.42.
- Boolean – Either true or false with no quotations.
- Null – Can only be null. It represents the absence of value.
Next up are math functions:
- Add: +
- Subtract: –
- Multiply: *
- Divide: /
Ok, Data types and build-in methods:
- Instance – and individual case (or object) or a data type.
- Length – the number of characters in an instance. (Example: console.log(‘Hello’.length); will return 5.
- .toUpperCase() – returns a string in all capitals.
- .startsWith() – returns a boolean based on the letter input in brackets.
- .trim() – trims blank spaces in an instance.
Time for a little more math. It will come in handy, I know it will:
- console.log(Math.random()); – returns a random number between 0 and 1.
- console.log(Math.random()*50); – returns a random number between 0 and 50.
- console.log(Math.floor(Math.random()*50)); – returns a random WHOLE number between 0 and 50.
- console.log(Math.ceil(43.8)); = 44 – returns the smallest integer greater than or equal to a number. In this case 43.8.
- Integer – A whole number
- console.log(Number.isInteger(2017)); – returns a boolean based on weather the number in brackets is a whole number.
Commenting out! The most useful thing in programming! Especially for keeping notes when working.
- let – Variables that can be reassigned.
const myName = ‘Arya’;
This will return: Arya.
- myName – name of a variable, in this case a const variable.
- = – assignment operator
- Arya – Value assigned to variable.
When adding them all together, we can use +. For example:
let favoriteAnimal = ‘Fox’;
console.log(“My favorite animal is ” + favoriteAnimal + “.”);
This will return: My favorite animal is Fox.
What have we learnt so far (according to Codecademy):
- Variables hold reusable data in a program.
- You can reassign variables that you create with the let keyword.
- Unset variables store the primitive data type undefined.
- Mathmatical assignment operators make it easy to calculate a new value and assign it to the same variable.
- The + operator is used to interpolate (combine) multiple strings.
Taking what I have learnt, I wanted to start to implement and experiment myself. However, when trying to get code to appear in Dreamweaver (the only program I’m familiar coding in), I found that I couldn’t get my simple code to appear.
So now the task at hand is sorting this problem before moving forward. Searching through a few forums and found them a little tricky to navigate especially with horrible text formatting and a lack of visual explanation. This leads me to YouTube. First video found is clear but still doesn’t solve my problem.
While searching, I did discover the Codecademy forum which included a number of beginners projects to try once I have figured this out. Good to know.
This next video I came across stated to show me a few things I didn’t know. Such as the alert function in HTML. Still something new, but not what I was learning in Codecademy. I shall quickly try what he has described.
This worked fine. Now on to see if I can get the rest to work as I originally learnt it.
- Codecademy (2018) Codecademy [Online] Available from: https://www.codecademy.com [Last Accessed: 31.01.2018]