10/7

I’m stuck again and having syntax errors.

And I struggled for a while, then I moved on. Now I’m making a little progress.

One of the functions i’m working on just had me write a formula for finding the perimeter of a rectangle, and I found that to be the easiest one I’ve written so far, because it called on things I already knew. When I was teaching English in Korea, I remember that my kindergarten-aged students always liked my math lessons the most, because they could understand what I was talking about very easily, because they were so familiar with the numbers (because math is so universal).

Ok, I just finished my functions lesson. I am very sure that I will need to go back and review the material the next time I am asked to code using functions, though.

ROCK PAPER SCISSORS:

I was hit with a challenge right off the bat.

This is the code required for the first task:

var userChoice = prompt( "Do you choose rock, paper or scissors?")

computerChoice = Math.random()

console.log(computerChoice)

if (computerChoice<=.33) {

computerChoice="rock";

} else if (computerChoice<=.66) {

computerChoice="paper";

} else {

computerChoice="scissors";

}

And I was able to figure it out, using hints, on my first try. Still, I was surprised when I hit the button, and it came out correctly.

Now I’m well underway with my rock paper scissor programming. There’s a lot of syntax to deal with, and I’m making some minor mistakes, but seem to be finding them. The “hints” are coming in handy. I just had an issue where I wasn’t using “else if” because it was the first time that had come up.

I’m caught on this:

var compare = function (choice1, choice2) {

if (choice1 === choice2) {

return "The result is a tie!"

}

if (choice1 === "rock") {

if (choice2 ==="scissors") {

return "rock wins."

}else {

return"paper wins."

}

}

else if(choice1 === "paper" {

if(choice2 ==="rock") {

return "paper wins."

}else {

return "scissors wins."

}

}

};

And just found out that I needed to do this:

var compare = function (choice1, choice2) {

if (choice1 === choice2) {

return "The result is a tie!"

}

if (choice1 === "rock") {

if (choice2 ==="scissors") {

return "rock wins."

}else {

return"paper wins."

}

}

else if(choice1 === "paper") {

if(choice2 ==="rock") {

return "paper wins."

}else {

return "scissors wins."

}

}

};

So just a little mistake, but time consuming. Moving on. Now I have completed my first attempt at entering the code for my rock paper scissor game. It is as follows:

var userChoice = prompt("Do you choose rock, paper or scissors?");

var computerChoice = Math.random();

if (computerChoice < 0.34) {

computerChoice = "rock";

} else if(computerChoice <= 0.67) {

computerChoice = "paper";

} else {

computerChoice = "scissors";

} console.log("Computer: " + computerChoice);

var compare = function (choice1, choice2) {

if (choice1 === choice2) {

return "The result is a tie!"

}

if (choice1 === "rock") {

if (choice2 ==="scissors") {

return "rock wins."

}else {

return"paper wins."

}

}

else if(choice1 === "paper") {

if(choice2 ==="rock") {

return "paper wins."

}else {

return "scissors wins."

}

}

else if (choice1==="scissors") {

if(choice2==="rock") {

return "rock wins."

}else{

return "scissors wins."

}

}

};

I’m going to call the function, enter my choices, and hope that I didn’t mess anything up. Let’s see! (I will chose rock (obviously)).

It worked!! And I won!!

Applications: Search Text for Your Name

I was flying through this lesson pretty well, but have hit a major wall on the “Your second for loop” page. It gives maybe 15 different explanations and examples that all have to come together on this page, and I have no idea which one I’m not understanding. I feel like I’m 70% sure on 10 different instructions it’s giving me for this specific page, so I have no idea which bit of code to tinker around with, because there’s simply too many options to rule out. This wasn’t particularly good design by Codecademy. I’ll mess around for a while and see if anything becomes clear.

Now it’s 20 minutes later… not much progress, though I got one of the error messages to give me a little hint. And now I’ve crashed the browser with each of my last two commands.

And it’s frozen a third time.

And a fourth time.

var myName= "Ty"

var hits = [];

for (i = 0; i<=text.length; i++){

console.log(i)

if(text[i]==='T') {

for(var j = i; j<=i+myName.length ; ) ;

hits.push("hey")

}

}

Is making this freeze, but I can’t figure out why.

Now I deleted one of the parameters of the second loop, and that caused all of my numbers to print in the log, but now I’m getting an error.

Now I’m back two days later… and I’m still stuck. I just froze the browser again. I’m not able to progress past this step.

I’m really frustrated.

This group is to support the Spring 2016 section of EDU 696M Computer Science for Teachers.

- Gerald Ardito on Ty's Course Reflection (): Ty, Thanks for your work in the course, and for your thorough and thoughtful...
- Gerald Ardito on Reflection (): Tamren, Thanks for your thoughful reflection -- really, for all of your...
- Gerald Ardito on mBot Dance Challenge! (): Beautifully done.
- Gerald Ardito on Reflection (): Rebecca, I really appreciate your reflection and the commitment and fun you...

robots4teachers, cs4tweek3, programming, computerscience, cs4tweek5, cs4tweek6, #codeisbeautiful, cs4tweek10, cs4tweek13, cs4tbyebye, #educationaltechnology #csforteachers #excited, media, software, visualization, etoys, computing, cs4tweek4, edtech, #cs4tweek4, #cs4tweek5, cs4tweek9, cs4tweek11, cs4tweek12, robot4teachers, dancechallenge, mbot, #csforbyebye, cs4tweek14