I attempted the following task but i am stuck on defining a boolean:
Define a function
getWalletFacts
that receives wallet, an object.
getWalletFacts
should return a sentence stating the wallet’s color and cash state.
My attempted code
const hascash = Boolean();
let wallet ={
color:"",
hascash:true||false,
write: function(sentence){
console.log(sentence);
}
};
function getWalletFacts(wallet){
let sentence= "my wallet is " + wallet.color+ " and " + wallet.hascash;
return sentence;
}
whenever i check my answer it tells me that hascash is undefined i.e
Expected: "My wallet is Black and has cash"
Received: "my wallet is Black and undefined"
from my understanding of the question hascash accepts a boolean
Given example
const wallet = {
color: "Black",
hasCash: true
};
getWalletFacts(wallet); // => 'My wallet is Black and has cash'
const wallet2 = {
color: "Grey",
hasCash: false
};
getWalletFacts(wallet2); // => 'My wallet is Grey and does not have cash'