####// Stuff you may need
// for loops. Ask in Gitter for an explanation (or look on google)
for (var i = 0; i < 10; i++) {
// code here
}
// length of a string
word.length
// conditionals
true != false // true
true == false // false
// string indexing
"apple"[3] // 'l'
ap = "apple"
ap[3] // 'l'
// a way to test.
http://codepen.io/
https://jsfiddle.net/
https://repl.it/languages/javascript
//------------------------
##REVERSE Challenge.
A piece of code is given the following input and gives the corresponding output.
What is that piece of code?
(Write something that gives the same output in the following test cases.)
// ----Test format--------
// Test #
// word1 word2 output
// -----------------------
Test 1
bring sling 2
Test 2
gouge gorge 1
Test 3
house rusty 5
Test 4
aa aa 0
Test 5
aa ab 1
Test 6
aa bb 2
Test 7
cost coat 1
Test 8
cost cowl 2
Test 9
cost bowl 3
Test 10
cost bawl 4
//--beginning of code-------
//--------------------------
function blackBox(a, b) {
word1 = a; //word1 will be "bring" in Test 1
word2 = b; //word2 will be "sling" in Test 1
//--------------------------
// Enter your code below here.
print('answer'); //print the output for the test case.
//--------------------------
}
// run the code with each of the test cases to see if your outputs match.
blackBox("bring", "sling");
// end of code--------
// post your solution on Gitter to discuss it :)
I've gotten carried away and made a little tester pen if you're too lazy to test it yourself. All you do is go into the JS, put in your solution, and click the Tests to check it. The tester pen seems to be broken on IE. can anyone figure out why and how to fix it?