Please help asap with an alignment of console.log output! | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Please help asap with an alignment of console.log output!

Guys, I have a code that generates a table, and I can't make it look good. The output should be in console.log only. Here is my code that works, but the output doesn't look as it supposed to(to test in in console just press Ctrl+Shift+i ): function displayWelcome() { console.log("Welcome! \nThis program will determine the time to pay off a credit card and the interest paid based on the current balance, the interest rate, and the monthly payments made.") } function calculateMinimumPayment(balance, minimumPayPercentage) { return Math.max(20, balance * minimumPayPercentage); } function displayPayments(balance, interest, minimumPay) { console.log("Your current balance is:

quot; + balance.toFixed(2)) console.log("Your interest rate is: " + (interest * 100) + "%") console.log("Your minimum payment is:
quot; + minimumPay) console.log("\nYear Balance Payment # Interest Paid") var year = 1; var interestPaid = 0; while (balance > 0) { interestPaid += balance * interest / 12; // principal paid should be calculated balance = Math.max(0, balance - (minimumPay - balance * interest / 12)); console.log(year + " " + balance.toFixed(2) + " " + interestPaid.toFixed(2)); year++; } } var currentBalance = 1500; var minimumPayPercentage = 0.02; var interest = 0.18; displayWelcome() var minimumPay = calculateMinimumPayment(currentBalance, minimumPayPercentage); displayPayments(currentBalance, interest, minimumPay);

26th Jun 2017, 11:13 PM
DIY Mods
DIY Mods - avatar
2 ответов
+ 1
Why do you want to do alignment in console.log? console log is for logging temporary debugging data, and should not use it for display your data in table form. Alignment can't be done in console log. Btw I remember you should have the ready made app template, but you not use it. (which I built it for you in your another bank account question thread, but I can't find it now, you deleted the thread!?)
27th Jun 2017, 3:20 AM
Calviղ
Calviղ - avatar
- 1
And here is how it supposed to looks like: PAYOFF SCHEDULE _________________ Year Balance Payment Num Interest Paid 1 1,492.50 1 22.50 1,484.89 2 44.89 1,477.16 3 67.16 1,469.32 4 89.32 . . . . . . 7 517.51 73 1,207.51 495.28 74 1,215.28 472.70 75 1,222.70 449.79 76 1,229.79 . . . . . . 8 227.51 85 1,277.51 200.92 86 1,280.92 173.94 87 1,283.94 146.55 88 1,286.55 118.74 89 1,288.74 90.53 90 1,290.53 61.88 91 1,291.88 32.81 92 1,292.81 3.30 93 1,293.30 0.00 94 1,293.35
26th Jun 2017, 11:17 PM
DIY Mods
DIY Mods - avatar