Write a JavaScript function that calculates and prints the sum of the first and the last elements in an array.
The input comes as array of string elements holding numbers.
Examples:
Input:
['20', '30', '40']
Output:
60
Input:
['5', '10']
Output:
15
The output is the return value of your function.