Git Product home page Git Product logo

speaking-grandma-london-web-career-042219's Introduction

Speak to Grandma

Objectives

  1. Control flow by using if, elsif, and else statements.
  2. Manipulate strings correctly.
  3. Evaluate the type case of a string.

Instructions

  1. Fork and clone this lab.
  2. Run the test suite using either the rspec or learn test command. You'll be coding your solution in grandma.rb.
  3. Write a speak_to_grandma method.
    • The method should take in a string argument containing a phrase and check to see if the phrase is written in all uppercase: if it isn't, then grandma can't hear you. She should then respond with (return) HUH?! SPEAK UP, SONNY!.
    • If you shout at her (i.e. call the method with a string argument containing a phrase that is all uppercase, then she can hear you (or at least she thinks that she can) and should respond with (return) NO, NOT SINCE 1938!.
    • However, if the phrase is exactly equal to: "I LOVE YOU GRANDMA!", then Grandma is very pleased and definitely hears that! and should repond with (return) I LOVE YOU TOO PUMPKIN!

A few things to think about:

  • You'll need to use if, elsif, and else statements to implement the logic of grandma responding with the appropriate string based on whether or not you speak to her in all uppercase, and/or whether you express your love.
  • Think about how we can check to see if a string is all uppercase. Reference the information below on manipulating strings.
  • Think about the response as a return value.

Manipulating Strings

One of the things you'll need to determine is if the argument that the speak_to_grandma method takes in is formatted a certain way (all uppercase).

There are many methods on the String class that manipulate strings. Let's take a look at a few:

"Hello World".upcase
#=> "HELLO WORLD"
"Hello World".reverse
#=> "dlroW olleH" 
"Hello World".downcase
#=> "hello world" 
"Hello World".capitalize
#=> "Hello world" 
"Hello World".swapcase
#=> "hELLO wORLD" 

Which one can we use to check that the argument string (i.e. what you're saying to Grandma) is all uppercase? You can use the comparison operator (==) to determine if the string you pass into your method call as an argument matches ("is equal to") that same string, but in uppercase form.

On that same note, we can also use the comparison operator to check and see if the string matches "I LOVE YOU GRANDMA!"

speaking-grandma-london-web-career-042219's People

Contributors

ahimmelstoss avatar annjohn avatar aviflombaum avatar deniznida avatar fislabstest avatar fs-lms-test-bot avatar kthffmn avatar lizbur10 avatar loganhasson avatar markedwardmurray avatar matbalez avatar maxwellbenton avatar mendelb avatar morgvanny avatar sarogers avatar sophiedebenedetto avatar timothylevi avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.