text: 'use strict';
  
  /********************************************************************************************
   *                                                                                          *
   * Plese read the following tutorial before implementing tasks:                             *
   * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates          *
   * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number  *
   * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math    *
   *                                                                                          *
   ********************************************************************************************/
  
  
  /**
   * Returns an area of a rectangle given by width and heigth.
   *
   * @param {numder} width
   * @param {number} height
   * @return {number}
   *
   * @example:
   *   5, 10 => 50
   *   5, 5  => 25
   */
  function getRectangleArea(width, height) {
      //throw new Error('Not implemented');
      var w = width;
      var h = height;
      return w*h;
  }
  
  
  /**
   * Returns a circumference of circle given by radius.
   *
   * @param {number} radius
   * @return {number}
   *
   * @example:
   *   5    => 31.41592653589793
   *   3.14 => 19.729201864543903
   *   0    => 0
   */
  function getCicleCircumference(radius) {
      //throw new Error('Not implemented');
      var p = 3.1415926535897932384626433832795;
      var r = radius;
      var result = 2*p*r;
      return result;
  }
  
  /**
   * Returns an average of two given numbers.
   *
   * @param {numder} value1
   * @param {number} value2
   * @return {number}
   *
   * @example:
   *   5, 5  => 5
   *  10, 0  => 5
   *  -3, 3  => 0
   */
  function getAverage(value1, value2) {
      throw new Error('Not implemented');
      // var n1 = value1;
      // var n2 = value2;
  
      // if ((n1+n2) == 0){
      //     return Infinity;
      // }else {
      // var result = (n1+n2)/2;
      // return result;
      // }
  }
  
  /**
   * Returns a distance beetween two points by cartesian coordinates.
   *
   * @param {number} x1
   * @param {number} y1
   * @param {number} x2
   * @param {number} y2
   *
   * @return {number}
   *
   * @example:
   *   (0,0) (0,1)    => 1
   *   (0,0) (1,0)    => 1
   *   (-5,0) (10,-10) => 18.027756377319946
   */
  function getDistanceBetweenPoints(x1, y1, x2, y2) {
      //throw new Error('Not implemented');
      var result = Math.sqrt((x2 -x1)**2 + (y2 - y1)**2);
      return result;
  }
  
  /**
   * Returns a root of linear equation a*x + b = 0 given by coefficients a and b.
   *
   * @param {number} a
   * @param {number} b
   * @return {number}
   *
   * @example:
   *   5*x - 10 = 0    => 2
   *   x + 8 = 0       => -8
   *   5*x = 0         => 0
   */
  function getLinearEquationRoot(a, b) {
      //throw new Error('Not implemented');
      var x;
      x = -b / a;
      if (typeof a === 'undefined') {
          x = -b;
      } else if (typeof b === 'undefined'){
          x = 0;
      }
    return x;
  }
  
  
  /**
   * Returns an angle (in radians) between two vectors given by xi and yi, coordinates in Cartesian plane
   * See details https://en.wikipedia.org/wiki/Euclidean_vector#Representations
   *
   * @param {number} x1
   * @param {number} y1
   * @param {number} x2
   * @param {number} y2
   * @return {number}
   *
   * @example:
   *   (1,0) (0,1)     => π/2
   *   (0,1) (0,-1)    => π
   *   (0,-1) (1,0)    => π/2
   *   (0,1) (0,1)     => 0
   *   (0,1) (1,2)     => 0
   */
  function getAngleBetweenVectors(x1, y1, x2, y2) {
      throw new Error('Not implemented');
  }
  
  /**
   * Returns a last digit of a integer number.
   *
   * @param {number} value
   * @return {number}
   *
   * @example:
   *   100     => 0
   *    37     => 7
   *     5     => 5
   *     0     => 0
   */
  function getLastDigit(value) {
     // throw new Error('Not implemented');
     //console.log(value);
     var lastnum = value.toString();
     var result = lastnum[lastnum.length-1];
     return result;
  }
  
  
  /**
   * Returns a number by given string representation.
   *
   * @param {string} value
   * @return {number}
   *
   * @example:
   *    '100'     => 100
   *     '37'     => 37
   * '-525.5'     => -525.5
   */
  function parseNumberFromString(value) {
      //throw new Error('Not implemented');
      var result = value;
      return +value;
  }
  
  /**
   * Returns a diagonal length of the rectangular parallelepiped given by its sides a,b,c.
   *
   * @param {number} a
   * @param {number} b
   * @param {number} c
   * @return {number}
   *
   * @example:
   *   1,1,1   => 1.7320508075688772
   *   3,3,3   => 5.196152422706632
   *   1,2,3   => 3.741657386773941
   */
  function getParallelipidedDiagonal(a,b,c) {
      //throw new Error('Not implemented');
      var d = Math.sqrt((a*a)+(b*b)+(c*c));
      return d;
  }
  
  /**
   * Returns the number rounded to specified power of 10.
   *
   * @param {number} num
   * @param {number} pow
   * @return {number}
   *  
   * @example:
   *   1234, 0  => 1234
   *   1234, 1  => 1230
   *   1234, 2  => 1200
   *   1234, 3  => 1000
   *   1678, 0  => 1678
   *   1678, 1  => 1680
   *   1678, 2  => 1700
   *   1678, 3  => 2000
   */
  function roundToPowerOfTen(num, pow) {
      throw new Error('Not implemented');
  }
  
  /**
   * Returns true is the number is prime; otherwise false.
   * See: https://en.wikipedia.org/wiki/Primality_test
   *
   * @param {number} n
   * @return {bool}
   * 
   * @example:
   *   4 => false
   *   5 => true
   *   6 => false
   *   7 => true
   *   11 => true
   *   12 => false
   *   16 => false
   *   17 => true
   */
  function isPrime(n) {
      //throw new Error('Not implemented');
      var prime = n != 1;
      for(var i=2; i<n; i++) {
          if(n % i == 0) {
              prime = false;
              break;
          }
      }
      return prime;
  }
  
  /**
   * Tries to convert value to number and returns it if conversion was successfull;
   * otherwise returns default value passed as a second argument.
   *
   * @param {any} value
   * @param {any} def
   * @return {number}
   *
   * @example
   *   toNumber(null, 0) => 0
   *   toNumber('test', 0) => 0
   *   toNumber('1', 0) => 1
   *   toNumber(42, 0) => 42
   *   toNumber(new Number(42), 0) => 42
   */
  function toNumber(value, def) {
      //throw new Error('Not implemented');
      var element = Number(value);
      
      if (Number.isInteger(element)){
          return element
      } else {
          return def;
     }
  }
  
  module.exports = {
      getRectangleArea: getRectangleArea,
      getCicleCircumference: getCicleCircumference,
      getAverage: getAverage,
      getDistanceBetweenPoints: getDistanceBetweenPoints,
      getLinearEquationRoot: getLinearEquationRoot,
      getAngleBetweenVectors: getAngleBetweenVectors,
      getLastDigit: getLastDigit,
      parseNumberFromString: parseNumberFromString,
      getParallelipidedDiagonal: getParallelipidedDiagonal,
      roundToPowerOfTen: roundToPowerOfTen,
      isPrime: isPrime,
      toNumber: toNumber
  };
  