WHAT is CODING?!
is it setting your PVR?
connecting up the stereo?
writing Python?
writing HTML, CSS, JavaScript?
... what ISN'T coding???
(image from http://www.bioprepper.com/2014/07/06/survival-communications-the-utility-of-morse-code/ )
What is it to you?
Homework: The Word Guesser
You'll create a simple word guessing game where the user gets infinite tries to guess the word (like Hangman without the hangman, or like Wheel of Fortune without the wheel and fortune).
- Create two global arrays: one to hold the letters of the word (e.g. 'F', 'O', 'X'), and one to hold the current guessed letters (e.g. it would start with '_', '_', '_' and end with 'F', 'O', 'X').
-
Write a function called guessLetter that will:
- Take one argument, the guessed letter.
- Iterate through the word letters and see if the guessed letter is in there.
- If the guessed letter matches a word letter, changed the guessed letters array to reflect that.
- When it's done iterating, it should log the current guessed letters ('F__') and congratulate the user if they found a new letter.
- It should also figure out if there are any more letters that need to be guessed, and if not, it should congratulate the user for winning the game.
- Pretend you don't know the word, and call guessLetter multiple times with various letters to check that your program works.
Bonus: Make it more like Wheel of Fortune
- Start with a reward amount of $0
- Every time a letter is guessed, generate a random amount and reward the user if they found a letter (multiplying the reward if multiple letters found), otherwise subtract from their reward.
- When they guess the word, log their final reward amount.
Bonus: Make it like Hangman!
- Keep track of all the guessed letters (right and wrong) and only let the user guess a letter once. If they guess a letter twice, do nothing.
- Keep track of the state of the hangman as a number (starting at 0), and subtract or add to that number every time they make a wrong guess.
- Once the number reaches 6 (a reasonable number of body parts for a hangman), inform the user that they lost and show a hangman on the log
Problem Solving!
- incremental, agile and iterative!
- unconditional love! :)
- ... and a bunch of crazy rules and fundamentals!
syntax (rules) and structure (fundamentals)!
... but how do you learn?
REPL (Read Evaluate Print Loop!)
- Tons and tons of tutorials out there! (what is your fav?)
- Mozilla Developer Network https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
- Learning Environments!
- Developer Tools!
- keeping it real...
- you will want to know how javascript, html and css all work together!
- JavaScript https://jsfiddle.net/
(AP Photo/Francois Mori)
Let's PLAY!!!!!
console.log("heeeeeellllooooo!!!");
var x = 3;
console.log(x);
Let's PLAY!!!!!
console.log("hello".toUpperCase());
console.log("3" + 4);
console.log(123 == "123");
console.log(123 === "123");
Let's PLAY!!!!!
var pet = "kittens";
if (pet == "puppies") {
pet += "!";
} else if (pet == "kittens") {
pet += "!!";
} else {
pet = "?" + pet;
}
console.log(pet);
Let's PLAY!!!!!
var obj = {
name: "Carrot",
details: {
color: "orange",
servingsize: 12
}
}
obj.details.servingsize;
Let's PLAY!!!!!
var obj = {
name: "Carrot",
details: {
color: "orange",
servingsize: 12
}
}
obj.details.servingsize;
obj.details.servingsize = 42;
obj.details.servingsize;
Let's PLAY!!!!!
var a = new Array();
a[0] = "dog";
a[1] = "cat";
a[2] = "hen";
for (var i = 0; i < a.length; i++) {
console.log(a[i]);
}
Let's PLAY!!!!!
var a = new Array();
a[0] = "dog";
a[1] = "cat";
a[2] = "hen";
for (var i = 0; i < a.length; i++) {
console.log(a[i]);
}
a.push("cow");
for (var i = 0; i < a.length; i++) {
console.log(a[i]);
}
Let's PLAY!!!!!
function add(x, y) {
var total = x + y;
return total;
}
add(2,3);
Let's PLAY!!!!!
function add(x, y) {
var total = x + y;
return total;
}
add(2,3);
console.log(total);
Let's PLAY!!!!!
function add(x, y) {
var total = x + y;
return total;
}
var i, tot;
for (i = 0; i < 10; i++) {
tot = add(2,i);
console.log(tot);
}
MORE!!!
- W3Schools!
- More Tutorials!
Coding!!!!
By Yvonne
Coding!!!!
Strengthening our CODING RELATED SKILLS!!!
- 1,181