forked from jsmapr1/simplifying-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem.js
More file actions
28 lines (24 loc) · 710 Bytes
/
problem.js
File metadata and controls
28 lines (24 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function getPrices() {
// START:formattedPrices
const prices = ['1.0', '2.15'];
const formattedPrices = [];
for (let i = 0; i < prices.length; i++) {
formattedPrices.push(parseFloat(prices[i]));
}
// END: formattedPrices
return formattedPrices;
}
function getPrices2() {
// START:pricesFloat
const prices = ['1.0', 'negotiable', '2.15'];
const formattedPrices = []; // <label id="code.collection"/>
for (let i = 0; i < prices.length; i++) { // <label id="code.iterator"/>
const price = parseFloat(prices[i]);
if (price) { // <label id="code.mix"/>
formattedPrices.push(price);
}
}
// END:pricesFloat
return formattedPrices;
}
export { getPrices, getPrices2 };