Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
01. Numbers
02. MMSA
03. Matrix of numbers
04. Lexicographically smallest
05. Hex to Decimal
README.md

README.md

Homework: Loops

Tasks marked with * require additional knowledge or some research

===============

01. Numbers from 1 to N

Description

Implement a javascript function that accepts an array with a single element - positive integer N as string and prints all the numbers from 1 to N inclusive, on a single line, separated by a whitespace.

Input

  • The input will consist of an array with a single element - the number N.

Output

  • The output should consist of a single line - the numbers from 1 to N, separated by a whitespace.

Constraints

  • N will be a valid positive 32-bit integer
  • Time limit: 0.2s
  • Memory limit: 16MB

Submit your code here


02. MMSA (Min, Max, Sum, Average) of N Numbers

Description

Implement a javascript function that accepts an array of floating-point numbers as strings and returns the minimal, the maximal number, the sum and the average of all numbers (displayed with 2 digits after the decimal point).

Input

  • The array that will be passed as a parameter to your function will contain the numbers of the sequence.

Output

  • You output must always consist of exactly 4 lines - the minimal element on the first line, the maximal on the second, the sum on the third and the average on the fourth, in the following format:
min=3.00
max=6.00
sum=9.00
avg=4.50

Constraints

  • 1 <= N <= 1000
  • All numbers will be valid floating-point numbers that will be in the range [-10000, 10000]
  • Time limit: 0.2s
  • Memory limit: 32MB

Submit your code here


03. Matrix of Numbers

Description

Write a javascript function that prints a matrix like in the examples below by a given integer N. Use two nested loops.

  • Challenge: achieve the same effect without nested loops.

Input

  • The input array will contain a single number as string, the integer N.

Output

  • See the examples.

Constraints

  • 1 <= N <= 20
  • N will always be a valid integer number
  • Time limit: 0.2s
  • Memory limit: 32MB

Submit your code here


04. Lexicographically smallest

Description

  • Write a script that finds the lexicographically smallest and largest property in document, window and navigator objects. Write the script in an external .js file and refer it from a html page.
  • Execute the same script under NodeJS. Why does it crash?

Submission

  • You do not have to submit anything for this task.

05. Hex to Decimal

Description

Using loops implement a javascript function that converts a hex number number to its decimal representation.

Input

  • The input will consists of a single line containing a single hexadecimal number as string.

Output

  • The output should consist of a single line - the decimal representation of the number as string.

Constraints

  • All numbers will be valid 64-bit integers.
  • Time limit: 0.1s
  • Memory limit: 16MB

Submit your code here

You can’t perform that action at this time.