Skip to content

Kristro/javascript-test-one

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

JavaScript Test

Complete all questions to the best of your abilities. You can use google, but you cannot ask other students or teachers for help. Also, do not copy code. Using Slack or something similar is not allowed! Everybody cheating gets 0 points, also the people who help.

Create an Name.js file (in my case it would be Martina.js) and work from there. Please do not forget to comment in the question number above your answers.

  1. Write a program to display the city name if the string begins with "Los" or "New" otherwise return "The city name does not begin with Los or New".

  2. Write a program to compute the sum of three elements of a given array of integers. The length of the array must be 3.

  • Example
  • [5, 10, 15] ➞ 30
  1. Given two strings, firstName and lastName, return a single string in the format "last, first".
  • Examples
  • "John", "Doe" ➞ "Doe, John"
  • "Mary", "Jane" ➞ "Jane, Mary"
  1. Write a program that takes an integer and returns true if it's divisible by 100, otherwise return false.
  • Examples
  • 1 ➞ false
  • 1000 ➞ true
  • 100 ➞ true
  1. Write a program that adds a string ending to each item in an array.
  • Examples & Expected output
  • ["clever", "meek", "hurried", "nice"], "ly" ➞ ["cleverly", "meekly", "hurriedly", "nicely"]
  • ["new", "pander", "scoop"], "er" ➞ ["newer", "panderer", "scooper"]
  • ["bend", "sharpen", "mean"], "ing" ➞ ["bending", "sharpening", "meaning"]
  1. Write a program that checks whether a number is even or odd and returns "even" for even numbers and "odd" for odd numbers.
  • Examples & Expected Output
  • 3 ➞ "3 is odd"
  • 146 ➞ "146 is even"
  • 19 ➞ "19 is odd"
  1. You are given 2 out of 3 angles of a triangle, in degrees e.g. 29° and 59°. Write a program that classifies the missing angle (the third angle of a triangle) as either "acute", "right", or "obtuse" based on its degrees.
  • Notes

  • An acute angle is smaller than 90°.

  • A right angle is exactly 90°.

  • An obtuse angle is greater than 90° (but smaller than 180°).

  • For example: 11°, 20° should return "obtuse", since the missing angle would be 149°, which makes it obtuse.

  • Examples

  • 27°, 59° ➞ Then the third angle is 92° so it is "obtuse"

  • 135°, 11° ➞ The third angle is "acute"

  • 45°, 45° ➞ The third angle is a "right angle"

  1. Make a variable with the string value of "maria jane jones". Convert each first letter to uppercase. Make sure your code works for any three names e.g. "john james smith".

  2. Write a program that takes a string and returns the word count. The string will be a sentence.

  • Examples Expected output
  • "This is an example" ➞ 4
  • "One more example for good measure" ➞ 6
  • "JavaScript is fun, right?" ➞ 4
  1. Write a program to multiply each value in an array by the number of items in that array.
  • Examples
  • [2, 3, 1, 0] (2 * 4), (3 * 4), (1 * 4), (0 * 4) ➞ [8, 12, 4, 0]
  • [4, 1, 1] ➞ [12, 3, 3]
  • [1, 0, 3, 3, 7, 2, 1] ➞ [7, 0, 21, 21, 49, 14, 7]
  • [0] ➞ [0]

Good luck! :)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%