Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Declare an array of five colors and print the first and last colors.

Easy

Problem Statement

Declare an array of five colors and print the first and last colors.

Sample Input

["red", "blue", "green", "yellow", "purple"]

Sample Output

red
purple

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Declare an array and print the first and last elements let colors = ["red", "blue", "green", "yellow", "purple"]; console.log(colors); console.log(colors);
Log in or sign up to run or submit your code.Log inSign up
Input
["red", "blue", "green", "yellow", "purple"]
Expected Output
red
purple