JS Practice Code

Function List

S.r No. Built in function / Pre-define function Example
1 Number
  • Description: It will convert string to number
  • return: It will give number value if it is valid if not then it will return NaN
  • let x = "5";
  • console.log(typeof x) //string but a valid number
  • x = Number(x) //it will convert string into number
  • console.log(typeof x) //number
  • console.log(x) //5
If number is not valid
  • let x = "test";
  • console.log(typeof x) //string but not a valid number
  • x = Number(x) //it will convert string into number but because of it is not a valid number it will convert only datatype like string to number and value will be NaN
  • console.log(typeof x) //number
  • console.log(x) //NaN
2 parseInt
  • Description: it will print integer value if it is float
  • return: it will write intiger value if it is valid number
isEven
3 isNan
  • Description: It will print Nan if it is not find a number
  • return: it return nothing if it not find any number
numberr
4 parseFloat
  • Description: it will give the exact value that we put it in
  • return: it will print exact number value if it is valid number
evenNumber
5 --- oddNumber
6 --- counting
7 --- sum
8 --- isDivisibleBy7
9 --- greatestNumberSq
10 --- squareOfNaturalNumber