Download presentation
Presentation is loading. Please wait.
Published byKellie Gilbert Modified over 9 years ago
1
Learn to code- JavaScript. Prt 1. TUTOR: DRKALMENIUS.
2
Simple syntax: You should learn the following syntax for JavaScript: At the end of a line(There are certain exceptions we will come across) you MUST put a semi- colon All ‘Commands’ should end with a parenthesis (eg. Console.log() ). To start with they should be empty but we will use ‘Parameters’ later. () are Parenthisis NOT brackets. {} These are brackets.
3
The 3 Main Data Types. There are 3 main data types you should be aware of: 1.Strings. Strings are just really bits of text. They can be anything, but a string HAS to be in-between “ ” or ‘ ’. The marks basically tell the IDE, or whatever you use to process your code, not to run it as code, or take it as any other data types. 2.Numbers. Numbers are, yes you guessed it, numbers. You can assign them variables, do calculations with them, and use them in many ways(such as randomising them) to add features to your code(sounds complicated but you’ll understand better when we come across ‘Rock, paper, Scissor’ ).Writing numbers needs no special syntax. Just write the number. 3.Booleans. Booleans (sounds complicated but are REALLY simple) are either true or false. They can be used in many ways, we will expand on this later.
4
The Console. The console is the area that contains all of the notes and the processes that have gone on. In most games and apps this is hidden, but in ‘Minecraft’ it appears before you load the actual app. If you use ‘codeacademy labs’ to write your code then it is the blue area on the right. URL: labs.codeacademy.com
5
Console.log() ‘console.log()’ is an extremely useful tool. It prints whatever data type is in the parenthesis to the console. Eg. console.log(“Hello”, 3, false); Becomes in the console: Hello 3 false console.log() has to be LOWER case!
6
Variables Ok! Nearly at a project! But first we’ve got variables to learn! This is going to be a bit different. I’ll show you the syntax then explain. ‘var consolePrint = console.log(“Me”);’ ‘var’ declares the variable. This is the name of the variable.It has to have the syntax: lowerUpperUpper(ext) This shows what the variable is equal to This is what the variable is equal to. It can be a whole range of things, but it can’t be more than one.
7
Prompt and Confirm These are both really simple concepts: 1.Prompt is a command that sends a notification to you with a box that you can type an answer in. If you declare a variable for the prompt you can refer to the answer later, by calling the variable or using it in a console.log(); (we will come across this in the first project.) 2.Confirm is a command that sends a notification to you with “OK” and “Cancel” replies. It can be used with variables the same as prompt.
8
Functions prt 1 – What they are. PHEW! Almost done and onto the first project. But first there is one REALLY important command we HAVE to learn. Functions are sort of like safes. They can hold loads of information, variables, commands and even other functions! Functions can be called up at any time.
9
Functions prt 2- Syntax Functions have two main ways of organising syntax. I will only show you one but you can find the other online in many places. var functionDemo = function(defualtValue){ console.log(defualtValue) } functionDemo(Hello) Declaring the variable Setting the variable equal to the function. This is a default value that,when we call the function, we can pass another value that, in the function, will replace the defualtValue. Printing the value we can pass to the console. Calling the function and passing Hello to replace the defualtValue
10
That’s it! That is all we need to know to make a simple greeting project! That will be on the next PowerPoint so go over there now and download it! Thanks for watching!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.