Code Monkey home page Code Monkey logo

hs-strings-mini-lab's Introduction

String Methods Interactive Practice

What will each of the following lines of code return?

???

String Practice

?: puts "i am super excited about coding!".upcase

( ) "I Am Super Excited About Coding!" (X) "I AM SUPER EXCITED ABOUT CODING!" ( ) "I aM sUPER eXCITED aBOUT cODING!"

?: puts "stressed".reverse

( ) "STRESSED" ( ) "sTrEsSeD" (X) "desserts"

?: puts "Hi! My name is Joe".swapcase

(X) "hI! mY NAME IS jOE" ( ) "HI! MY NAME IS JOE" ( ) "hi! my name is joe"

?: puts "short string".length

(X) 12 ( ) 11 ( ) 2

?: puts "backwards".reverse.upcase

( ) "sdrawkcab" ( ) "BACKWARDS" (X) "SDRAWKCAB"

???

???

Now it's your turn to use string methods.

?: Get enthusiastic about ruby! How do I print out "I love ruby" in all caps?

( ) '"I love Ruby".swapcase' (X) '"I love Ruby".upcase' ( ) '"I love Ruby".uppercase'

?: Use a method to print out how long this sentence is: "This is a pretty long string. I wonder how long it is?"

(X) '"This is a pretty long string. I wonder how long it is?".length' ( ) '"This is a pretty long string. I wonder how long it is?".swapcase' ( ) '"This is a pretty long string. I wonder how long it is?".printlength'

?: It's backwards day! How would you print "backwards" backwards?

( ) '"backwards".length' ( ) '"backwards".backwards' (X) '"backwards".reverse'

?: Wouldn't it be great if there was a string method that always capitalized the first letter of a string? There is! "make it capitalize the first letter in this string!"

( ) '"make it capitalize the first letter in this string!".upcase' ( ) '"make it capitalize the first letter in this string!".swapcase' (X) '"make it capitalize the first letter in this string!".capitalize'

?: How much do we love "Ruby"? So much that we want to say it in all caps AND backwards. How would you do this?

( ) '"Ruby".captialize.reverse' ( ) '"Ruby".reverse.swapcase' (X) '"Ruby".upcase.reverse'

???

View String Methods Interactive Practice on Learn.co and start learning to code for free.

hs-strings-mini-lab's People

Contributors

dfenjves avatar fs-lms-test-bot avatar ipc103 avatar mikespangler avatar stephaniecoleman avatar vanessadean avatar victhevenot avatar

Watchers

 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.