DEV Community

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)