Challenge: Functions

Implement a function that returns the last character of a string.

We'll cover the following

Task

Write a function called lastChar that accepts a string as an argument and returns the last letter of the string.

Sample input 1:

JavaScript

Expected output:

t

Sample input 2:

Hello world

Expected output:

d

Sample input 3:

A

Expected output:

A

Get hands-on with 1400+ tech skills courses.