From 559302775b8daf48b41e3ebf2951e6c643b92231 Mon Sep 17 00:00:00 2001 From: Michael Newman Date: Wed, 19 May 2021 16:16:38 +0000 Subject: [PATCH] Done. --- index.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/index.js b/index.js index e69de29bb..8fa27fdf9 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,74 @@ +function shout (string) { + return string.toUpperCase () +} + +/* describe('whisper(string)', function() { + it('receives one argument and returns it in all lowercase', function() { + expect(whisper('HELLO')).toEqual('hello') + }) +})*/ + +function whisper (string) { + return string.toLowerCase () +} + +/* describe('logShout(string)', function() { + it('takes a string argument and logs it in all caps using console.log()', function() { + const spy = expect.spyOn(console, 'log').andCallThrough() + + logShout('hello') + + expect(spy).toHaveBeenCalledWith('HELLO') + + console.log.restore() + }) +}) */ + + +function logShout(string) { + console.log(string.toUpperCase()) +} + +/* describe('logWhisper(string)', function() { + it('takes a string argument and logs it in all lowercase using console.log()', function() { + const spy = expect.spyOn(console, 'log').andCallThrough() + + logWhisper('HELLO') + + expect(spy).toHaveBeenCalledWith('hello') + + console.log.restore() + }) +}) */ + +function logWhisper(string) { + console.log(string.toLowerCase()) +} + + +/* describe('sayHiToGrandma(string)', function() { + it('returns "I can\'t hear you!" if `string` is lowercase', function() { + expect(sayHiToGrandma('hello')).toEqual("I can't hear you!") + }) + + it('returns "YES INDEED!" if `string` is uppercase', function() { + expect(sayHiToGrandma('HELLO')).toEqual("YES INDEED!") + }) + + it('returns "I love you, too." if `string` is "I love you, Grandma."`', function() { + expect(sayHiToGrandma("I love you, Grandma.")).toEqual("I love you, too.") + }) +}) */ + + +function sayHiToGrandma(string){ + if (string === string.toLowerCase()){ + return "I can\'t hear you!" +} + if (string === string.toUpperCase()){ + return "YES INDEED!" + } + if (string === "I love you, Grandma."){ + return "I love you, too." + } +}