Git Product home page Git Product logo

cssi-prework-javascript-string-lab's Introduction

String Manipulation - L337

Since you are gaining entry into the nerd universe, it's time to learn l33t (leet). l33t is encoding of sorts that manipulates strings using certain rules l33t on Wikipedia.

For this lab, we will 2 basic l33t rules.

  1. Substitute the vowels a,e,i and o.
  • a becomes 4
  • e becomes 3
  • i becomes 1
  • o becomes 0
  1. Replace all whitespace with a $

** Note on replacement:** The .replace() function in javascript will only replace the first instance of the substring that is being searched for. For example, if I use .replace() to replace "o" with "0" in "Food" the return value will be "F0od". To replace a substring globally, you can either string together a bunch of .replace() methods, which is inefficient, or you can use Regular Expressions (We'll learn more about these in Python). Regular expressions are a way of searching for patterns in strings, and are delineated by forward slashes. To replace all of the "o"s in "food", we'd write:

"food".replace(/o/g, "0")

The content inside // is what is the pattern being searched for, and the "g" afterwards stands for for "global" - this means we're looking for every instance of 'o' in the string.

Use this as a template when you build out your l33t converter!

Instructions

  1. Fork and clone this lab (either through github or by clicking on the 'open' button in Learn). cd into the lab directory.

  2. Open index.html in the browser. You can open html files by using the command line or by using Finder.

  3. Open the JavaScript console within the browser to see any messages.

  4. Press the "l33t It" button and you'll see the encoder just returns the original userString.

  5. Open encoder.js. Follow the instructions in the comments to add code that translates userString into basic l33t before it is returned.

  6. Run learn to make sure the function passes the tests!

cssi-prework-javascript-string-lab's People

Contributors

nanselmo avatar dfenjves avatar

Watchers

James Cloos 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.