-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem-3.js
More file actions
23 lines (17 loc) · 814 Bytes
/
Copy pathproblem-3.js
File metadata and controls
23 lines (17 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function calculateAiCost(tokensUsed) {
// input gulo number/negative kina check korlam, jodi na hoy tahole Invalid return korbe
if (typeof tokensUsed !== "number" || tokensUsed < 0) {
return "Invalid";
}
// jodi 500 token ba tar kom use hoy tahole kono taka dite hobe na
if (tokensUsed <= 500) {
return 0;
}
// notun ekta variable set korlam free 500 token bad diye remaining token ber korar jonno
let extraTokens = tokensUsed - 500;
// notun arekta variable set korlam remaining token theke koyta complete 100 token ache seta ber korar jonno
let chargeableTokens = Math.floor(extraTokens / 100);
// notun arekta variable set korlam chargeable token diye mot khoroch ber korar jonno
let totalCost = chargeableTokens * 5;
return totalCost;
}