Programming - Workshop 3
-
Upload
cas-lemmens -
Category
Self Improvement
-
view
776 -
download
1
description
Transcript of Programming - Workshop 3
![Page 1: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/1.jpg)
ProgrammingCas Lemmens - Workshop 3
![Page 2: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/2.jpg)
So far we’ve seen...
Variables
Mathematical functions
Boolean Logic
Loops
Conditionals
Arrays
Strings
Functions
![Page 3: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/3.jpg)
Arraysfruits.push();
fruits.unshift();
fruits.pop();
fruits.shift();
fruits.splice();
fruits.concat();
fruits.length;
fruits.toString();
![Page 4: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/4.jpg)
Procedural programmingStrings
![Page 5: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/5.jpg)
var welcome:String = “Hyper Island”;
![Page 6: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/6.jpg)
var welcome:String = “Hyper Island”;
H y p e r I s l a n d
![Page 7: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/7.jpg)
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 8: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/8.jpg)
Value of an index
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 9: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/9.jpg)
Value of an index
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.charAt(8);
![Page 10: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/10.jpg)
Value of an index
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.charAt(8);
8
![Page 11: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/11.jpg)
Value of an index
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.charAt(8);
8
l
![Page 12: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/12.jpg)
Value of an index
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.charAt(8);
variable answer has value ”l”
8
l
![Page 13: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/13.jpg)
Index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 14: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/14.jpg)
Index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:uint = welcome.indexOf(‘e’);
![Page 15: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/15.jpg)
Index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:uint = welcome.indexOf(‘e’);
e
![Page 16: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/16.jpg)
Index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:uint = welcome.indexOf(‘e’);
3
e
![Page 17: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/17.jpg)
Index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:uint = welcome.indexOf(‘e’);
variable answer has value 3
3
e
![Page 18: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/18.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 19: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/19.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.indexOf(‘e’);
![Page 20: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/20.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.indexOf(‘e’);
e
![Page 21: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/21.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.indexOf(‘e’);
3
e
![Page 22: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/22.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.indexOf(‘e’);
variable answer has value 3
3
e
![Page 23: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/23.jpg)
First index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.indexOf(‘e’);
variable answer has value 3
3
e
![Page 24: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/24.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 25: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/25.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘e’);
![Page 26: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/26.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘e’);
e
![Page 27: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/27.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘e’);
3
e
![Page 28: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/28.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘e’);
variable answer has value 3
3
e
![Page 29: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/29.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘e’);
variable answer has value 3
3
e
![Page 30: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/30.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 31: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/31.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘z’);
![Page 32: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/32.jpg)
Last index of a value
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:int = welcome.lastIndexOf(‘z’);
variable answer has value -1
![Page 33: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/33.jpg)
Slicing an array
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
![Page 34: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/34.jpg)
Slicing an array
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.slice(2,8);
![Page 35: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/35.jpg)
Slicing an array
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.slice(2,8);
3
e2
p4
r5 6
I7
s
![Page 36: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/36.jpg)
Slicing an array
var welcome:String = “Hyper Island”;
p e r I s2 3 4 5 6 7
var answer:String = welcome.slice(2,8);
3
e2
p4
r5 6
I7
s
![Page 37: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/37.jpg)
Slicing an array
var welcome:String = “Hyper Island”;
p e r I s2 3 4 5 6 7
var answer:String = welcome.slice(2,8);
variable answer has value “per Is”
3
e2
p4
r5 6
I7
s
![Page 38: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/38.jpg)
Splitting an array
var welcome:String = “Hyper Island”;
H y p e r I0 1 2 3 4 5 6
s l a n d7 8 9 10 11
![Page 39: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/39.jpg)
Splitting an array
var welcome:String = “Hyper Island”;
H y p e r I0 1 2 3 4 5 6
s l a n d7 8 9 10 11
var answer:Array = welcome.split(7);
![Page 40: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/40.jpg)
Splitting an array
var welcome:String = “Hyper Island”;
H y p e r I0 1 2 3 4 5 6
s l a n d7 8 9 10 11
var answer:Array = welcome.split(7);
variable answer has value
7
s
![Page 41: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/41.jpg)
Splitting an array
var welcome:String = “Hyper Island”;
H y p e r I0 1 2 3 4 5 6
s l a n d7 8 9 10 11
var answer:Array = welcome.split(7);
variable answer has value
7
s
“Hyper I”“sland”
![Page 42: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/42.jpg)
Making a substring
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
I6
![Page 43: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/43.jpg)
Making a substring
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.substr(3,4);
I6
![Page 44: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/44.jpg)
Making a substring
var welcome:String = “Hyper Island”;
H y p e r I s l a n d0 1 2 3 4 5 6 7 8 9 10 11
var answer:String = welcome.substr(3,4);
3
e4
r5
I66
I
![Page 45: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/45.jpg)
Making a substring
var welcome:String = “Hyper Island”;
e r I3 4 5 6
var answer:String = welcome.substr(3,4);
3
e4
r5
I66
I
![Page 46: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/46.jpg)
Making a substring
var welcome:String = “Hyper Island”;
e r I3 4 5 6
var answer:String = welcome.substr(3,4);
variable answer has value “er l”
3
e4
r5
I66
I
![Page 47: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/47.jpg)
Making a substring
var welcome:String = “Hyper Island”;
e r I3 4 5 6
var answer:String = welcome.substr(3,4);
variable answer has value “er l”
3
e4
r5
I66
I
1 2 3 4
![Page 48: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/48.jpg)
Making a substring
var welcome:String = “Hyper Island”;
e r I
var answer:String = welcome.substr(3,4);
variable answer has value “er l”
3
e r II
4
![Page 49: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/49.jpg)
Making a substring
var welcome:String = “Hyper Island”;
e r I
var answer:String = welcome.substr(3,4);
variable answer has value “er l”
3
e r II
4
![Page 50: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/50.jpg)
Strings
answer.charAt(8);
answer.indexOf(‘e’);
answer.lastIndexOf(‘e’);
answer.slice(8);
answer.split(8);
answer.substr(5);
![Page 51: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/51.jpg)
Procedural programmingFunctions
![Page 52: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/52.jpg)
function name(parameter:Paramtype, ...):ReturnType{
// *** MAGIC ***}
![Page 53: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/53.jpg)
function makeHyperIslandEmailAddress(name:String, surname:String):String
{var emailAddress:String =
name + “.” + surname + ‘@hyperisland.se’;return emailAddress;
}
![Page 54: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/54.jpg)
RTFM!
Check the docs!
![Page 55: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/55.jpg)
Exercise 10Awesomeness!
![Page 56: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/56.jpg)
No homework, but please...
Overlook it...
Experiment with it...
Ask questions!
Remember: this is only the start!
So please, get this!
![Page 57: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/57.jpg)
Q&A
![Page 58: Programming - Workshop 3](https://reader034.fdocuments.in/reader034/viewer/2022051513/545388fcb1af9f8c228b4652/html5/thumbnails/58.jpg)
Thanks!