Today’s coding session progressed seamlessly. We tackled a plethora of ‘if’ statements, providing me with ample opportunity to hone my skills.
I ventured to the library, virtually, to peruse their selection to break from my current literary endeavor of Safe People. My curiosity led me to select Part of Your World, which boasts impressive reviews. I’m eager to delve into this book and see if it lives up to its hype.
Can I gripe more about Safe People? I was reading about the importance of having safe people in our lives on Safe People. While having safe people in our lives is crucial, some of the statements made in the article made me question things. According to the book, Monday blues (the casual term that describes the negative feelings some people experience at the beginning of the workweek) have nothing to do with work but our lack of intimacy. It is difficult to believe that this is always the case. Additionally, the article suggests that if we have difficulty completing tasks, it’s because of how God constructed us. While I agree that having toxic people in our lives can have negative consequences, I don’t think that God has anything to do with our ability to complete tasks.
During therapy today, I discussed the themes presented in Safe People and addressed the challenge of forgiveness. I gathered from our conversation that it’s essential to stop allowing negative individuals to take up space in our minds and to consciously make an effort to let go of any residual hurt or anger. I also shared my difficulties comprehending certain religious concepts in the book. My therapist was understanding and offered to clarify any questions I may have. Despite this, I still find it hard to connect with the religious references in the text. We also touched on Mother’s Day, and my therapist suggested that I focus on making a positive gesture, like sending a card, to my mom without expecting anything in return. He encouraged me to enjoy the day with my girls and keep my actions centered on my well-being.
I will complain about this book as long as I have to read it. I’m 50% through the book so far.
We are picking up Alexis from school this weekend for the summer. I wonder if Tommy and I are heading to her school tomorrow or Saturday. Chris will be coming home on Saturday. Everest is already here. She and Merlin played outside for a few hours. Karissa cleaned her room and came out with 4 trash bags. Wow!
We are having tikka masala tonight. 🙂
JavaScript notes…
——————————–
Freecodecamp Forum Leaderboard steps 21 – 40
Step 21
In the fourth td element, add an embedded expression that contains the views variable. This will display the number of views the post has.
return `${title}
${posts_count - 1} ${views} Step 22
To display data in the Activity column, you need to use the bumped_at property of each topic, which is a timestamp in the ISO 8601 format. You need to process this data before you can show how much time has passed since a topic had any activity.Create a new arrow function called timeAgo with a parameter called time.
const timeAgo = (time) => { }Step 23
Inside the timeAgo function, create a constant called currentTime and assign new Date() to it.const timeAgo = (time) => { const currentTime = new Date(); };Step 24
Create a new constant called lastPost and assign new Date(time) to it.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); };Step 25
Create a constant called timeDifference that will store the difference between currentTime and lastPost.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); const timeDifference = currentTime - lastPost; };Step 26
Create a constant named msPerMinute that will store the number of milliseconds in a minute. There are 1000 * 60 milliseconds in a minute.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); const timeDifference = currentTime - lastPost; const msPerMinute = 1000 * 60; };Step 27
Create a constant named minutesAgo and assign it Math.floor(timeDifference / msPerMinute) to get the number of minutes ago the post was created.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); const timeDifference = currentTime - lastPost; const msPerMinute = 1000 * 60; const minutesAgo = Math.floor(timeDifference / msPerMinute); };Step 28
Create a constant named hoursAgo that will store the number of hours that have passed since the last post. You can do this by dividing minutesAgo by 60, and then rounding down to the nearest whole number.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); const timeDifference = currentTime - lastPost; const msPerMinute = 1000 * 60; const minutesAgo = Math.floor(timeDifference / msPerMinute); const hoursAgo = Math.floor(minutesAgo / 60); };Step 29
Create a constant named daysAgo that will store the number of days that have passed since the last post. You can do this by dividing hoursAgo by 24, and then rounding down to the nearest whole number.const timeAgo = (time) => { const currentTime = new Date(); const lastPost = new Date(time); const timeDifference = currentTime - lastPost; const msPerMinute = 1000 * 60; const minutesAgo = Math.floor(timeDifference / msPerMinute); const hoursAgo = Math.floor(minutesAgo / 60); const daysAgo = Math.floor(hoursAgo / 24); };Step 30
The next step is to return the number of minutes ago the post was created.Create an if statement that checks if minutesAgo is less than 60. If it is, then return the template literal ${minutesAgo}m ago.
if (minutesAgo < 60) { return `${minutesAgo}m ago`; }Step 31
Next, create another if statement to check if hoursAgo is less than 24. If it is, then return the template literal ${hoursAgo}h ago, which represents the number of hours ago the post was created.if (hoursAgo < 24) { return `${hoursAgo}h ago`; }Step 32
Below your if statements, return a template literal with ${daysAgo}d ago which will show how many days ago the post was created.return `${daysAgo}d ago`;Step 33
To display the time since the last post, call the timeAgo function and pass in the bumped_at variable for the argument. Place this function call inside the last td element.Once you make those changes, scroll across the table to see the new values displayed in the Activity column.
${timeAgo(bumped_at)}Step 34
You need a function to convert view counts to a more readable format. For example, if the view count is 1000, it should display as 1k and if the view count is 100,000 it should display as 100k.Create an arrow function called viewCount with a parameter called views.
const viewCount = (views) => {}Step 35
Create a constant named thousands and assign Math.floor(views / 1000) to it. This will give you the number of thousands in the views variable rounded down to the nearest thousand.const viewCount = (views) => { const thousands = Math.floor(views / 1000); };Step 36
Next, create an if statement that checks if views is greater than or equal to 1000. If it is, return the template literal ${thousands}k.if (views >= 1000) { return `${thousands}k`; }Step 37
Lastly, return the views variable which will show the amount of views less than 1000.return views;Step 38
Inside the fourth td element, update the current value to instead call the viewCount function with the views variable as an argument.${viewCount(views)} Step 39
Each of the forum topics includes a category like Python or JavaScript. In the next few steps, you will build out a category object which holds all of the forum categories and classNames for the styling.Start by creating a new constant called allCategories and assign it the value of an empty object.
const allCategories = {}Step 40
Inside your allCategories object, add a new key for the number 299 with a value of an empty object.Inside that object, add a property with a key of category and a string value of Career Advice. Below that property, add another key called className with a string value of career.
const allCategories = { 299 : { category: "Career Advice", className: "career" } };Category: Uncategorized