Skip to content

Instantly share code, notes, and snippets.

@outoftime
Last active February 7, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save outoftime/ff81842b39762b463441c66643aeff41 to your computer and use it in GitHub Desktop.
Save outoftime/ff81842b39762b463441c66643aeff41 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=ff81842b39762b463441c66643aeff41
<!DOCTYPE html>
<html>
<head>
<title>Guess the value</title>
<script src="https://cdn.rawgit.com/outoftime/f52d5b141348be500e17085e5af3aba6/raw/925c1b7f32a518aae732db41ff18532f03bfa985/guess.js"></script>
</head>
<body>
<h1>Guess the value</h1>
<ol id="results"></ol>
<hr>
<p>This input is used in several questions: <input id="answer" value="winter" disabled></p>
</body>
</html>

Guess the value

In the JavaScript code, there are ten calls to the function guess(). In each case, the function’s first argument is a string value, and the second argument is an expression of some kind.

Your mission is to guess the value of all ten expressions. Currently, all ten guesses are just a question mark, which is not the correct answer to any question.

Change the question mark to the correct value for the expression given as the second argument to guess() in each case.

If you are correct, the output for that number will turn green.

You may not modify any other code besides changing the contents of the first argument to guess().


Finish early?

See how far you can get in Code Combat.

{"enabledLibraries":["jquery"],"hiddenUIComponents":["console","editor.css"]}
// 1
guess("?", "Tuesday");
// 2
var city = "Brooklyn";
guess("?", city);
// 3
var firstName = "Westing";
var lastName = "house";
guess("?", firstName + lastName);
// 4
guess("?", lastName + ", " + firstName);
// 5
guess("?", $("#answer").val());
// 6
var whichSeason = $("#answer").val();
guess("?", whichSeason);
// 7
guess("?", "It is currently " + whichSeason);
// 8
guess("?", "Now is the " + $("#answer").val() + " of our discontent");
// 9
function greet(name) {
var greeting = "Hello, " + name;
guess("?", greeting);
}
greet(firstName);
// 10
function makeObservation(condition) {
guess("?", "Looks like it's " + condition);
}
makeObservation($("#answer").val());
body {
font-family: Helvetica;
}
h1 {
text-align: center;
}
.result.correct {
background-color: lightgreen;
}
.result.incorrect {
background-color: salmon;
}
.result {
border: 1px solid gray;
padding: 0.5em;
}
code {
font-weight: bold;
font-size: 1.5em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment