Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sumFirstAndLast(input) {
- let firstElement = Number(input[0]);
- let lastElement = Number(input.pop());
- console.log(firstElement + lastElement);
- }
- OR
- function sumFirstAndLast(input) {
- input = input.map(Number);
- console.log(input[0] + input.pop());
- }
Advertisement
Add Comment
Please, Sign In to add comment