My first ever software?!
I know i still will need to do this few more time before i completely understand! Any feedback for critiqe would be warranted!
- pick random number for objects arrays
- made variable that will hold the arrays data
- iterated through the arrays (declared order?)
- conditionals with the random message being pushed
- will make better
function generateRandomNumber(num) {
// Gets # from 0 -> num - 1
return Math.floor(Math.random() * num)
}
const ixAmMessages = {
excuse: ['tried to catch you earlier!', 'hey, dont worry about yesterday', 'sorry i slept in late, just wanted to say'],
IxAM: ['YOUxARE', 'WExARE'],
motivated: ['Better Than That', 'Learning', 'Not Giving Up!', 'Going to Work Harder', 'Going to the Gym'],
attractive: [' You are so freakin Beautiful', 'you are hot and Handsome', ' dang! Looking Great!', ' are you Losing Weight?', 'taking care of yourself'],
}
// puts the 'talk' in an array
let ixAmTalk = []
//! add another array to the object
// iterate through arrays
for (let talk in ixAmMessages) {
let order = generateRandomNumber(ixAmMessages[talk].length)
switch (talk) {
case 'excuse':
case 'IxAM':
case 'motivated':
case 'attactive':
ixAmTalk.push(`'${ixAmMessages[talk][order]}'!`)
break
default:
ixAmTalk.push('and i oop! hold up!')
}
}
// random indices for each property
const randomExcuseIndex = Math.floor(Math.random() * ixAmMessages.excuse.length);
const randomIxAMIndex = Math.floor(Math.random() * ixAmMessages.IxAM.length);
const randomMotivatedIndex = Math.floor(Math.random() * ixAmMessages.motivated.length);
const randomAttractiveIndex = Math.floor(Math.random() * ixAmMessages.attractive.length);
// random items from each property
const randomExcuseItem = ixAmMessages.excuse[randomExcuseIndex];
const randomIxAMItem = ixAmMessages.IxAM[randomIxAMIndex];
const randomMotivatedItem = ixAmMessages.motivated[randomMotivatedIndex];
const randomAttractiveItem = ixAmMessages.attractive[randomAttractiveIndex];
//? make flow better
// combined message
const combinedMessage = `${randomExcuseItem} ${randomIxAMItem} ${randomMotivatedItem} and ${randomAttractiveItem}`;
// Log the combined message to the console
console.log(combinedMessage);
When posting your project for review, please be sure to include the following:
- Your review of the Project. Was it easy, difficult, just right?
- An estimate of how long it took you to complete
- The link to your code repo
We hope you enjoyed this project!