Basic Programs
Fundamental JavaScript programs to get started with programming
10 program solutions
Program Solutions
Hello World
The classic first program that prints "Hello World" to the console
Display Your Name
Program to display your name using variables
User Input
Program to take input from user using prompt()
Sum of Two Numbers
Program to add two numbers
Swap Two Numbers
Program to swap values of two variables
JavaScript Data Types
Program demonstrating different data types in JavaScript
Arithmetic Operations
Program demonstrating all arithmetic operations
Convert Fahrenheit to Celsius
Program to convert temperature from Fahrenheit to Celsius
Calculate Simple Interest
Program to calculate simple interest
Area and Perimeter of Rectangle
Program to calculate area and perimeter of a rectangle
Topic Strategy: Basic Programs
This topic is best practiced through repetition with variation. Solve each program, then modify constraints and test alternate approaches so you understand why one solution performs better than another.
During interviews, explain the approach before coding: input assumptions, core logic, complexity, and edge cases. Clear reasoning often matters as much as final code correctness.
Once comfortable, time-box each question and target clean, readable code with meaningful variable names and a quick dry run explanation.