Get first n characters of string

Write a function that takes a string (a) as argument. Get the first 3 characters of a. Return the result
function
myFunction
(
a
)
{

return
}
Test Cases:
myFunction('abcdefg')
Expected
'abc'
myFunction('1234')
Expected
'123'
myFunction('fgedcba')
Expected
'fge'

How to solve it

To get the first n characters of a string, I would use the slice method again.
As we have seen in previous tasks, we can use the slice method to extract a part of a string without modifying the original string.
For this task we will use both parameters of the slice method (startIndex and endIndex). startIndex should be 0 because we want to start at the beginning of the array. endIndex should equal the index of the first character that you do not want to be included in the result. Remember that strings are zero-indexed in Javascript (see this challenge for more information). Hence, if we want to extract the first n characters of a string, endIndex should simply equal n.
console.log('wxyz'.slice(0,2));
// output: 'wx'