DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Christian Falucho
Christian Falucho

Posted on • Updated on

Day 2 of #100DaysOfCode!

Today's progressπŸ€–

Successful day! I tackled on more Basic Algorithm Scripting
problems from freeCodeCamp. Learned and used a wide set of methods, slice() splice() indexOf(). A combination of methods can really help to solve algorithms. So reading and really understanding what they do helps.

What I learned

split() method divides a string into an ordered list of substrings and returns an array.

let string = "I'm a little tea pot"

let arr = string.split(' ');

//output: ['I'm', 'a', 'little', 'tea', 'pot']
Enter fullscreen mode Exit fullscreen mode

Now that we have the string into an array. We can loop through the array and take the first letter of each word and replace it using the toUpperCase method

splice() method modifies an existing array by removing, replacing or adding existing elements.

let numbers = ['one', 2, 4, 'five', 'six', 7]

numbers.splice(2, 0, 'three')  


//output ['one', 2, 'three', 4, 'five', 'six', 7]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

🌚 Life is too short to browse without dark mode