Parsing Numbers

Parsing Numbers
0

#1

guys i am stucked in this exercises where it asks for:

makeInt(n) parses n as an integer and returns the parsed integer:
Error: Expected undefined to equal 455
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
at Context. (test/index-test.js:34:35)

makeInt(n) assumes base 10:
Error: Expected undefined to equal 0
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
at Context. (test/index-test.js:38:31)

  1. preserveDecimal(n) preserves n’s decimals (it parses n as a floating pointnumber) and returns the parsed number:
    Error: Expected undefined to be 2.222
    at assert (node_modules/expect/lib/assert.js:29:9)
    at Expectation.toBe (node_modules/expect/lib/Expectation.js:66:28)
    at Context. (test/index-test.js:48:38)makeInt(n) assumes base 10:

#2

this is my code so far.

function makeInt(n){
parseInt(‘45.5’, 10)
}
function preserveDecimal(n){
parseFloat(‘2.222’)
}


#3

try adding return before parseInt and parseFloat


#4

I did it with parsefloat and I got it.
ParseINT wasnt that lucky


#5

function makeInt(n){
parseInt(‘n’, 10)
}
function preserveDecimal(n){
return parseFloat(n)
}


#6

makeInt(n) parses n as an integer and returns the parsed integer:
Error: Expected undefined to equal 155
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
at Context. (test/index-test.js:34:35)

  1. makeInt(n) assumes base 10:
    Error: Expected undefined to equal 0
    at assert (node_modules/expect/lib/assert.js:29:9)
    at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
    at Context. (test/index-test.js:38:31)