- You do not need to fork or clone this repository. Simply follow the instructions.
- Use a separate Repl.it for each problem.
- Write JavaScript code to obtain the data prompted by each question.
Each solution should be in its own repl.it project so you will need to submit 5 links to your instructors. Slack solution URLs directly to both instructors.
Write a program that calculates the area of a rectangle. Create variables to hold the length and the height and use them in the area calculation:
Rectangle area = length x width
Print the calculated area for the user.
Write a program that calculates the area of a triangle. Create variables to hold the base and the height and use them in the area calculation:
Triangle area = 1/2 x base x height
Print the calculated area for the user.
Write a program that calculates the area of a circle. Create a variable to hold the radius and use it in the area calculation:
Circle area = Pi x radius x radius
Print the calculated area for the user. The value for PI is built into JavaScript. How do we access it?
Write a program that calculates the circumference of a circle. Create a variable to hold the radius and use it in the area calculation:
Circle circumference = Pi x radius x 2
Print the calculated circumference for the user.
Write a program that calculates the volume of a sphere. Create a variable to hold the radius and use it in the area calculation:
Sphere volume = 4/3 x Pi x radius x radius x radius
Print the calculated volume for the user.
Given these three strings:
var str1 = 'Software';
var str2 = 'Development';
var str3 = 'Rules';
Write a program that will concatenate them into a single string. First, use the concatenation operator (+) and then rewrite your solution to use the String.concat() function. Print out the resulting string for the user. BONUS: Add spaces between the words in the resulting string.
A pangram is a string containing all letters of the alphabet. Given the string:
var str = 'The quick brown fox jumps over the lazy dog'
Find the index of the first occurrance of the letter 'z'. Try a few other letters - since it is a pangram every letter should be present. Print out the index of the letter for the user.
Given the following string:
var str = 'The quick brown fox jumps over the lazy dog'
Write a program that checks to see if it contains the following sub-strings:
var substr1 = 'ump';
var substr2 = 'brown';
var substr3 = 'Quick';
Print true
or false
to indicate if the sub-string is present.
Based on the results, is the comparison case-sensitive or case-insensitive?
Given the following string:
var str = 'The quick brown fox jumps over the lazy dog'
We want to modify the string to change the animals' descriptions. Change 'quick' to 'small' and change 'lazy' to 'sleeping'. Print the modified string.
Given the following string:
var str = 'I am a lasagna hog';
Write a program that will print only the word lasagna.
- All content is licensed under a CC-BY-NC-SA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].