Skip to main content
fixed typo
Source Link
cqx
  • 3.5k
  • 4
  • 12
  • 34

You are concenatingconcatenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding integers so it results in: 200000000000000000

You are concenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding integers so it results in: 200000000000000000

You are concatenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding integers so it results in: 200000000000000000

fixed wrong word
Source Link
cqx
  • 3.5k
  • 4
  • 12
  • 34

You are concenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding stringsintegers so it results in: 200000000000000000

You are concenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding strings so it results in: 200000000000000000

You are concenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding integers so it results in: 200000000000000000

Source Link
cqx
  • 3.5k
  • 4
  • 12
  • 34

You are concenating strings in JavaScript.

Here is what happens:

var test = "he";
var test2 = "llo";
console.log(test+test2);

OUTPUTS: hello. You are using integers as strings.

Therefore you need to convert your variables to int before adding them.

Here is an example:

highestBidAmount = parseInt(highestBidAmount, 10);

Sidenote: Don't change the 10 it has nothing to do with decimal places. It's the radix used.

Do that with both variables:

minBidIncrement = parseInt(minBidIncrement, 10);

Now add them:

let minNextBid = highestBidAmount + minBidIncrement;

Now you are adding strings so it results in: 200000000000000000