Crow's Codes 001: JavaScript Iterators

in #coding6 years ago

codes-coding-computer-270366.jpg
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


Connect with me on:

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)

Sort:  

Great tutorial wonder if there is an a way that we can get highlighted code on a steemit alternative interface and connect with a web runtime.

That would be really interesting! Do you have an alternate interface in mind or would it be a new one?

No but I met the developer of busy which could probably integrate that feature if there was enough demand.

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

Awesome! Thanks for the support.

This post has received a 100.00 % upvote from @steemdiffuser thanks to: @jeremycrow.

Bids above 0.05 SBD may get additional upvotes from our trail members.

Get Upvotes, Join Our Trail, or Delegate Some SP

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by JeremyCrow from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

!bookkeeper drugwars

!bookkeeping drugwars

Hi @jeremycrow!

drugwars

Received:

  • 0.009 STEEM from daily
  • 0.006 STEEM from heist
  • 0.000 STEEM from referral

Spent:

  • 0.993 STEEM

Total:

  • -0.978 STEEM

First transfer was before 0.76 days.
Your ROI per day is 2.00 % and you are earning approx. 0.02 STEEM per day.
Break even in approx. 49.3 days.

!bookkeeping drugwars

Hi @jeremycrow!

drugwars

Received:

  • 0.018 STEEM from daily
  • 0.015 STEEM from heist
  • 0.000 STEEM from referral

Spent:

  • 0.993 STEEM

Total:

  • -0.960 STEEM

First transfer was before 2.25 days.
Your ROI per day is 1.48 % and you are earning approx. 0.01 STEEM per day.
Break even in approx. 65.5 days.

!bookkeeping drugwars

Hi @jeremycrow!

drugwars

Received:

  • 0.027 STEEM from daily
  • 0.015 STEEM from heist
  • 0.000 STEEM from referral

Spent:

  • 0.993 STEEM

Total:

  • -0.951 STEEM

First transfer was before 2.83 days.
Your ROI per day is 1.49 % and you are earning approx. 0.01 STEEM per day.
Break even in approx. 64.1 days.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 63688.35
ETH 3125.30
USDT 1.00
SBD 3.97