Download presentation
Presentation is loading. Please wait.
1
JavaScript/ App Lab Programming:
Simple JavaScript Commands and Creating Functions
2
Introduction to App Lab:
So far the extent of our coding experience has been through web design. We have written HTML and CSS files to help us design some websites. Although we have written code, this type of coding isn’t wouldn’t be normally considered “real” programming. Today we are going to begin to learn to program and the language we are going to start with is JavaScript using the App Lab programming environment. JavaScript is a very important language especially since it is used for many websites. JavaScript can be used to make a website much more interactive. First we must learn some JavaScript code before we can apply it to websites. Using App Lab will teach you how to program in JavaScript by using a block language which allows for code to be created easily with very few compiling errors.
3
Using App Lab: Computers are machines. So if we invent an instruction or command for a computer to execute, then it should be unambiguous how the computer will interpret or attempt to execute that instruction. To use App Lab we are going to create an account on Code Studio and register for the class. Use the link below: Once you are registered, Go to Unit 3 Stage 4 and begin completing all the parts in stage 4. Combine blocks together to sequence different pieces of code together. You are limited to four commands only for this exercise
4
Efficiency Discussion:
What strategies or reasoning did you use to identify possible solutions? Is the solution that you or another group found the most efficient? How do you know? What does “efficiency” mean? “Efficiency” can mean different things depending on the context. When we try to create efficient programs, what other valuable resources might we be concerned about conserving?
5
Why limit to only 4 Commands?
App Lab has much more than four basic commands, so why did the widget limit your ability? Collaborative problem-solving skills are important factors in programming. Being able to get together with other people to talk about and make reasoned arguments about the best ways to code things is what professionals do. Creativity You need to understand how to use the features of a programming language to solve a problem. You will always be constrained by the programming language. The reason you need to learn how to program is because there isn’t a command to do every little thing; you have to understand the set of things that a programming language can do, and then use your creativity and problem-solving skills to get the computer to do what you want.
6
Function Transition: In the previous lesson we created simple turtle drawings using only four commands. At some point you probably wished that more commands were available to you. Describe a command you wanted to be able to use and explain why you wanted to use it. Think of commands you wish you had to complete the last task! Programming languages will always have some commands that are already defined, but there will be many instances when the exact command we want isn’t available. To add more functionality to our language we can create our own commands or functions. We’ve seen functions before in Java and now we are going to create our own functions to add more functionality to our programs.
7
Functions in JavaScript/App Lab
We are going to transition back to App Lab and continue practicing your programming skills. You will still be limited to the four commands as before but that is all you will need to create the functions required. A Function is simply a sequence of commands that will be performed when that function called upon. For the most part we will be dealing with programs that follow a certain style when being created Camelcase : Multi-word function names are made a single word which begins in lowercase and uses uppercase letters to indicate the start of a new word. For example: thisFunctionNameIsCamelcase() **Function Definition at the Bottom : Function definitions appear at the bottom of the program. This is done so that the first line of the program is the first line of code actually run (Opposite format also common) Function Names Can’t Start with Numbers: In most programming languages, including JavaScript, function names are not allowed to begin with numbers or most symbols. Underscore, however, is allowed.
8
Creating Functions in App Lab:
Go to Unit 3 Stage 5 and work on parts 2 – 8. You will be defining new functions from the four commands given to us which will allows us to use even more commands! Follow the prompts in the sections and complete all the tasks in Stage 5. Creating functions in JavaScript is somewhat similar to how it is done in Java, but it is a little easier to understand and create functions using App Lab.
9
Function Benefits: List the benefits of being able to define and call functions in a program. Who specifically gets to enjoy those benefits? Write this in your Do Now Journal
10
Function Benefits Answered:
List the benefits of being able to define and call functions in a program. Who specifically gets to enjoy those benefits? programs are easier to read and write functions remove the need to repeat large chunks of code functions break the program into logical chunks The person programming and any other human reading the program enjoys these benefits. Important to note: functions do not make the program easier (or harder) for the computer to run or understand – it must still run all of the same commands as before.
11
App Lab Commands and Functions:
Today we learned very simple JavaScript commands along with the basics of creating functions in JavaScript. We will continue to strengthen our knowledge of JavaScript commands in future lessons. We will expand on our knowledge of commands we have available to us along with learning how to create more advanced functions. Keep on practicing the tutorials on Code Studio so that you have a good understanding of what is going on.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.