Image courtesy of Pexels.com
This is the first of a series of blog posts in which I will document some of the code I learned or worked on every day. My aim is to post a bare minimum of one line of code every single day for 365 days straight. This one year challenge was inspired by Coding Phase. For more information, visit his YouTube channel and his main website.
#CodingPhase #TheCodingWay #365CodingPhaseChallenge
Just to give a bit of background, I have never really gotten heavy into coding but I have learned the basics of several programming languages over the course of my life. This has mainly been in relation to my education in electronics or so that I could code my own website. Some of the languages I have been exposed to include Basic, Visual Basic, Turing, C, C+, Assembly Language, HTML and CSS.
A few days ago I started learning JavaScript for the first time. I've been going through the free online course offered by Codecademy titled: Introduction to JavaScript
Today I've been going through the section on Iterators.
I was presented with the following code defining an array of strings:
const words = ['unique', 'uncanny', 'pique', 'oxymoron', 'guise'];
I was challenged with checking if there are words in this array that are fewer than 6 characters long. This should log either "true" or "false" to the console. The code I came up with created a function using the .some and .length methods and in this case returns the result of "true":
console.log(words.some((word) => { return word.length < 6; }));
Using the .filter method I created a new array of strings from the words array which will have more than 5 characters using the following code:
const interestingWords = words.filter(word2 => word2.length > 5);
Finally, I had to check to see if every string in the new array actually does only contain words with more than 5 characters each. To achieve this I used the .every method:
console.log(interestingWords.every((word) => { return word.length > 5; } ));
If you enjoyed this record of my experience learning to code and want to follow along going forward, please consider adding me on Twitter and following my blog here on Steemit:
https://steemit.com/@jeremycrow
My Website: JeremyCrow.com
Minds: Minds.com/JeremyCrow
Twitter: Twitter.com/JeremyCrow
Patreon: Patreon.com/jeremycrow
Instagram: Instagram.com/jeremycrow
YouTube: YouTube.com/user/ZigguratOfEnki
BitChute: BitChute.com/JeremyCrow (sign up here)