DEV Community

loading...

Day 2 of #100DaysOfCode!

Christian Falucho
Passionate about building websites and web applications that can be used by millions of people. I hope to build tools that can help people.
Updated on ・1 min read

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

Discussion (0)