• Thursday , 4 June 2020

20 String Methods in 7 Minutes – Beau teaches JavaScript

Code Canyon



String methods featured in this video: charAt, charCodeAt, concat, endsWith, fromCharCode, includes, indexOf, lastIndexOf, match, repeat, replace, search, slice, split, startsWith, substr, substring, toLowerCase, toUpperCase, trim.

Code:
🔗 http://codepen.io/beaucarnes/pen/qRLzNX?editors=0012

Other resources on topic:
🔗 https://www.w3schools.com/jsref/jsref_obj_string.asp

Beau Carnes on Twitter: https://twitter.com/carnesbeau

⭐JavaScript Playlists⭐
▶JavaScript Basics: https://www.youtube.com/playlist?list=PLWKjhJtqVAbk2qRZtWSzCIN38JC_NdhW5
▶ES6: https://www.youtube.com/playlist?list=PLWKjhJtqVAbljtmmeS0c-CEl2LdE-eR_F
▶Design Patterns: https://www.youtube.com/playlist?list=PLWKjhJtqVAbnZtkAI3BqcYxKnfWn_C704
▶Data Structures and Algorithms: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkso-IbgiiP48n-O-JQA9PJ
▶Clean Code: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkK24EaPurzMq0-kw5U9pJh


We’re busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Join our community at https://freecodecamp.com
Follow us on twitter: https://twitter.com/freecodecamp
Like us on Facebook: https://www.facebook.com/freecodecamp
Follow Quincy on Quora: https://www.quora.com/Quincy-Larson

Original source

3d Ocean

Related Posts

23 Comments

  1. Tom Wexler
    April 2, 2019 at 16:27

    Excuse me for a very stupid, layman question, but what is the point in having things being returned in the console and not on the site itself? I've seen some of the more overt uses of JS, but I'm having a major blockage in learning the use of it. Hell, i'm even starting to understand the syntax pretty well without understanding the point! Any advice is massive. Thank you!

  2. Zombie Machine
    April 2, 2019 at 16:27

    very useful

  3. Gangavaram Diwakar
    April 2, 2019 at 16:27

    Nice 👌👌👌👌👌👌 sirji

  4. Purna Mahesh
    April 2, 2019 at 16:27

    <html>

    <head>

    <script type="text/javascript">

    var a = "mahesh";

    var b = "naresh";

    for(var i=0;i<a.length;i++){

    for(var j=0;j<b.length;j++){

    if(a.charAt(i)==b.charAt(j)){

    a.replace(a.charAt(i),'');

    b.replace(b.charAt(j),'');

    i–;

    break;

    }

    }

    }

    document.write("<h2>"+a+" "+b+"</h2>");

    </script>

    </head>

    </html>

    why my code isn't working?

  5. Daniel Garr
    April 2, 2019 at 16:27

    i got lost at /end/g

  6. Cameron Chardukian
    April 2, 2019 at 16:27

    Watching this video as a newbie Javascript developer was super insightful. A perfect crash course on possibilities of cool things you can do to modify strings in Javascript.

  7. Carlos Nani
    April 2, 2019 at 16:27

    It was very very useful. Thanks a lot.
    I´d love 20 methods from another. 🙂

  8. Gilson Viana
    April 2, 2019 at 16:27

    In my opinion, for beginners is far more effective to learn – how to interact with object types – using LOOPS and CONDITIONALS then to learn a dozen of prototype methods. Not saying that you DON'T need to learn it though.

  9. Karim Benzema
    April 2, 2019 at 16:27

    Grand Summary

    charAt – returns character at specified index, myString.charAt(1) will return SECOND letter of string myString.

    charCodeAt – same as charAt but returns unicode instead.

    concat – concatenates string1 and string2, string1.concat(string2) // string1+string2

    endsWith – condition check to determine if a given string ends with a certain character or string; string1.endsWith("abc")
    ,
    fromCharCode – converts unicode values to characters, it is a static method of the String object, so you type String.fromCharCode(desiredCharCode) , where String is the string object and not any arbitrary string.

    includes – checks whether the string includes a specified character/string..

    indexOf – tells the index of a specified string or character in the input string; inputString.indexOf("Dog"). In case of TWO or more occurrences of the same string/char in the inputString, it will tell index of only the first occurrence !

    lastIndexOf – same as indexOf() but returns the index of the LAST occurrence of the specified char or string in the input string.

    match – searches the input string for matches of the REGULAR EXPRESSION specified and returns them in an array.

    repeat – repeats the string a specified number of times, inputString.repeat(3) // 3 times repeat inputString !

    replace – searches a string for a specific sub-string or REGULAR EXPRESSION and replaces it with the specified string. inputString.replace("end", "END")

    search – searches the string for a specified sub-string or REGULAR EXPRESSION and tells it's position.

    slice – slices or extracts a specified portion of the inputString. inputString.slice(2,4), returns the stuff from index 2 till index 3

    split – splits the string, into an array of sub-strings, upon the occurrence of the character specified. e.g inputString.split(" ") will split the string EVERYTIME a space (" ") occurs in the inputString and push the character coming UP TILL the space as a new entry in the array. ( but not including the space itself ? )

    startsWith – checks if a string begins with a specified character/sub-string; conditional check.

    substr – similar to slice, extracts a sub-string from the inputString, starting from the given initialIndex, and going up to the number of subsequentDigits, including the character at initialIndex in the count as well. inputString.substr(initialIndex, subsequentDigits) . Watch in video if it's hard to understand.

    substring – Ditto copy of slice, better to look at https://stackoverflow.com/a/2243835 for a better understanding of differences.

    toLowerCase – makes ALL the letters in string to lower case

    toUpperCase – exact opposite of toLowerCase() .

    trim – removes WhiteSpace from EITHER SIDE of the inputString; inputString.trim().

  10. Jean-Francois Simard
    April 2, 2019 at 16:27

    'Care.' …ok

  11. Anna Maria
    April 2, 2019 at 16:27

    Excellent! Loved it.

  12. Altoids10
    April 2, 2019 at 16:27

    How many string methods do you people need?

  13. AkU GOMS
    April 2, 2019 at 16:27

    whats the use of this all?

  14. Soft We
    April 2, 2019 at 16:27

    Good one…..

  15. Mr. Fresh
    April 2, 2019 at 16:27

    Is there a way freeCodeCamp can use bigger font, or zoom method so that we can see everything from the source code and the console.log……..Thanx

  16. Toby Henderson
    April 2, 2019 at 16:27

    Thank You Beau, the code pen was super helpful actually, I was getting confused on algorithms because of syntax and I kept getting more and more confused. After coming back from a few day break I found this string methods module and now I can test strings on it every time. MDN seems over complicated they should be simplifying complex problems as you are here.

  17. DMoots
    April 2, 2019 at 16:27

    Thanks man this was so handy!

  18. Galejandro84 Ensenada
    April 2, 2019 at 16:27

    Excelent video

  19. Kenny Zzy
    April 2, 2019 at 16:27

    how many string methods are there? Do you have to memorise it ?

  20. Sergi
    April 2, 2019 at 16:27

    Great stuff.

  21. Joe Bloe
    April 2, 2019 at 16:27

    why would you use stringOne.charAt(1), when in the previous video you could just use stringOne[1]

  22. Tyrese143
    April 2, 2019 at 16:27

    Very helpful! I also recommend reading this post on the unwritten rules of JavaScript Strings
    https://medium.com/@tyresedev/the-unwritten-rules-of-javascript-strings-5adbea15cbef

Leave A Comment

You must be logged in to post a comment.