var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256
// try using parsInt(x)
// you can then use typeof(x) to confirm
var myString = "555";
var myInt = parseInt(string);
console.log(typeof myInt); // number
var text = '42px';
var integer = parseInt(text, 10);
// returns 42
let myNumber = Number("5.25"); //5.25
<script language="JavaScript" type="text/javascript">
var a = "3.3445";
var c = parseInt(a);
alert(c);
</script>
var string = "10";
var integer = parseInt(string);
console.log(typeof(integer)); // int
var text = '42px';
var integer = parseInt(text, 10);
// returns 42
var text = '3.14someRandomStuff';
var pointNum = parseFloat(text);
// returns 3.14
var num = parseInt(<string value>);
// parseInt is one of those things that you say wtf javascript?
//if you pass to it any argument with number first and letters after, it
// will pass with the first numbers and say yeah this a number wtf?
let myConvertNumber = parseInt('12wtfwtfwtf');
console.log(myConvertNumber);
// the result is 12 and no error is throw or something
//but this
let myConvertNumber = parseInt('wtf12wtf');
console.log(myConvertNumber);
// is NaN wtf?
//if you truly want an strict way to know if something is really a real number
// use Number() instead
let myConvertNumber = Number('12wtf');
console.log(myConvertNumber);
// with this if the string has any text the result will be NaN
const stringPrices = ['5.47', '3.12', '8.00', '5.63', '10.70'];
let priceTotal = 0;
// priceTotal should be: 32.92
// Write your code below
stringPrices.forEach(stringPrice => {
price = parseFloat(stringPrice);
priceTotal += price;
});
parseInt(string)