GithubHelp home page GithubHelp logo

javascript-test-one's Introduction

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! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.