Conversation
| defendingPlayer.health -= (baseDamage + variableDamage) | ||
| let totalDamage = baseDamage + variableDamage | ||
|
|
||
| console.log(` |
There was a problem hiding this comment.
Just a key idea I wanna point out . . . you want to return a string, not console.log() . .. because that's what line 69 is doing! But, as you can see when you run the program, line 69 logs undefined because this attack() function does not return any value.
Keep in mind that console.log() is a tool for developers to see their code while they write. But it's far more important to actually be returning the values our functions calculate.
| const [attackingPlayer, defendingPlayer] = attackOrder; | ||
| console.log(attack(attackingPlayer, defendingPlayer, 1, 2)); | ||
| // had to update the parameter for variable damage so it could be truely random | ||
| console.log(attack(attackingPlayer, defendingPlayer, 1, Math.floor(Math.random() *10))); |
There was a problem hiding this comment.
this logs undefined instead of a string that is returned by the function.
| const seattleSaleTax = .0375 | ||
| const wholeSalesTax = washingtonSalesTax + seattleSaleTax | ||
|
|
||
| function Receipt(){ |
There was a problem hiding this comment.
Remember the good naming conventions, variables and functions ought to always begin with a lowercase letter and use camelCase. By naming this function with a capital R you might create the impression that is is a Class, not a function.
| THANK YOU! | ||
| `) | ||
| } | ||
| Receipt(logReceipt) No newline at end of file |
There was a problem hiding this comment.
The formatting is really nice, but unfortunately this implementation negates the idea of having a logReceipt() function. Keep in mind with these starter files that you don't want to change the part that is already there . . . The setup wants to run a function named logReceipt() that you are tasked with writing, and then give it those provided values.
So a couple lessons here . . . logReceipt() is meant to be a reusable piece of code that can take any number of given parameters. This is the core of writing functions, being able to use that bit of code over and over again with variable inputs. One key tool that needs to be used is a spread operator, so that it will work if given 1,2,3, or 1000 menu items.
What's happened here instead is making logReceipt() just a static array, and not a function at all, then getting the desired output with a static, single-purpose function Receipt() that can only ever do this one job.
Try again, simplify things, and let the boilerplate run logReceipt() as a function that takes the three objects.
| // Returns total number of points won | ||
|
|
||
|
|
||
| function getTotalPoints(string){ |
There was a problem hiding this comment.
Don't overlook the helpers provided. See how the object RESULT_VALUES and function getPointsFromResult are here to do some of this work for you?
No description provided.