You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
759 B
JavaScript
26 lines
759 B
JavaScript
export const pembulatan500 = function (number) {
|
|
if (typeof number === 'number') {
|
|
let num = number.toString();
|
|
if (num.length > 3) {
|
|
let numPart = Number(num.substring(num.length - 3, num.length));
|
|
let numbers = Number(num) - numPart;
|
|
if (numPart > 500) {
|
|
return numbers + 1000;
|
|
} else {
|
|
return numbers + 500;
|
|
}
|
|
} else {
|
|
if (Number(num) > 500) {
|
|
return 1000;
|
|
} else {
|
|
return 500;
|
|
}
|
|
}
|
|
} else {
|
|
if(typeof Swal != 'undefined'){
|
|
Swal('Info', 'data pembulatan 500 tidak berformat number');
|
|
}
|
|
throw 'data bukan number';
|
|
}
|
|
}
|