What if first choice is rock?


#1

var compare = function (choice1, choice2){
if (choice1 = choice2){
return "The result is a tie!"
}
else if (choice1 === "rock"){
if (choice2 === "scissors"){
return "rock wins;
}
else {
return "paper wins";
}
}
}

can anyone see anything wrong with my code. Thanks in advance


#2

It just might be because you need another " after wins


#3

Thank you, Great eye. That was becoming frustrating


#4

No problem! I hate when that happens. You do all this hard work and then a grammar error is keeping you from moving on...xD Happy coding!


#5

Hey Bibleman, was wondering if you could help me with another problem. Im onto while loops and I can't seen to get the code right. Here is my code, let me know if you see anything wrong. Thanks in advance

//Remember to set your condition outside the loop!
var count = 0

var loop = function(i === 0; i < text.length; i++){
while(count < 3){
//Your code goes here!
console.log("I am looping!")
}
};

loop();


#6

Well first off, as humbling as taking a hint can be to someone with a pride like mine xD the hint for this is very good. I would suggest looking at the hints before asking. However, lets take a look at this!

This is unnecessary for solving this lesson here. However, hang on to it, you will need in the future many times!

The main idea that you are missing here which was stated in the hint and I quote "if we create a variable called count and set it to 0 outside the loop (on line 2), then do count++ each time we console.log() inside the loop, we'll be able to track how many loops we've made. If we set the while condition to be count < 3, that should do the trick!"
I can give you a basic outline if needed but those two things should help you solve this :smiley:


#7

OK, that made more sense but still not running properly

I rewrote the code

var count = 0

var loop = function(count++){
while(count < 3){
console.log("I'm looping!");
//Your code goes here!
}
};

loop();


#8

Ok so your very close. Count++ doesn't go in the function as a parameter but it does go in the while loop :smiley:


#9

Hello again Bibleman, I rewrote the code again.
var count = 0

var loop = function(){
while(count < 3; count++){
console.log("I'm looping!");
//Your code goes here!
}
};

loop();

Am i missing something?
Ps really appreciate the help, hope I am not bothering you


#10

Sorry again for the late responce. I have been sick as of late so it just wasn't happening too much yesterday. So basically you need your count++ outside but inside. As in outside your console.log statement but inside as in before you close it out with } };. So basically right where your code goes here ironically enough lol.


#11

Hey ,Thank you, it worked. Sorry about my late response been working. I hope you are feeling better.

I have one more question that maybe you could help me with. Im learning JS because it seems the most beneficial for creating an interactive website. How would I go about object manipulation (e.g placing points on a map)?


#12

Thanks I am feeling a little better and I gotcha in the working area haha. Well believe it or not I don't know everything. :open_mouth: Yes, you can reattach your jaw. While I like to think, atleast, I am good at javascript, when it comes to websites and all, I have very little experience. However, if you post that same question in the community corner you will get plenty of answers to help you out. Also, there is always google. As silly as that sounds there are a lot of really good internet resources online to look at for these things.


#13

Hahaha. ok I just thought id through it out there to see. But thanks for all the help on this problem set. I have been looking around on the internet and there seems to be a lot of different resources. So I guess I will just have to pick one and go from there.


#14

And honestly, just because I don't know doesn't mean you can't find good help here! Believe me, it never hurts to ask! If I was a moderator I would move your question to a new post in the community forum but....I lack those really cool buttons haha. But whatever you may choose to do, it has been nice helping you and chatting and I wish you the best of luck as you go onward on your coding journey! :smiley: Let me know how it goes when you get your first web page running and all :thumbsup:


#15

Hey, the pleasure has been all mine. Thank you for all your help. You were awesome.

Cheers my friend


#16

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.