Skip to content

Instantly share code, notes, and snippets.

@punkrocker178
Created August 18, 2018 07:07
Show Gist options
  • Save punkrocker178/4f1d4a592d22320885130a91e92d55d8 to your computer and use it in GitHub Desktop.
Save punkrocker178/4f1d4a592d22320885130a91e92d55d8 to your computer and use it in GitHub Desktop.
Thinkful Unit 2 Lesson 2 Jaavascript drills
/*-----------------------Drill 1----------------------*/
function wisePerson(wiseType, whatToSay) {
// your code here
var a = "A wise "+wiseType+" once said: \""+whatToSay+
"\".";
return a;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
*/
// tests
function testWisePerson() {
var wiseType = 'goat';
var whatToSay = 'hello world';
var expected = 'A wise ' + wiseType + ' once said: "' +
whatToSay + '".';
var actual = wisePerson(wiseType, whatToSay);
if (expected === actual) {
console.log('SUCCESS: `wisePerson` is working');
}
else {
console.log('FAILURE: `wisePerson` is not working');
}
}
/*-----------------------Drill 2----------------------*/
function shouter(whatToShout) {
// your code here
return whatToShout.toUpperCase()+"!!!";
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
*/
// tests
function testShouter() {
var whatToShout = 'fee figh foe fum';
var expected = 'FEE FIGH FOE FUM!!!';
if (shouter(whatToShout) === expected) {
console.log('SUCCESS: `shouter` is working');
}
else {
console.log('FAILURE: `shouter` is not working');
}
}
testShouter();
/*-----------------------Drill 3----------------------*/
function textNormalizer(text) {
// your code here
return text.toLowerCase().trim();
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
*/
// tests
function testTextNormalizer() {
var text = " let's GO SURFING NOW everyone is learning how ";
var expected = "let's go surfing now everyone is learning how";
if (textNormalizer(text) === expected) {
console.log('SUCCESS: `textNormalizer` is working');
}
else {
console.log('FAILURE: `textNormalizer` is not working');
}
}
testTextNormalizer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment