JS array.find()

JavaScript has many array methods that can help you solve a variety of problems. One of those methods is the find() method. The find() method executes a callback function on each element in an array until it finds the first element where callback returns a true value.

Syntax

array.find(callback(element[, index[, array]])[, thisArg])

Parameters

callback

  • A function that executes on each element in the array, taking three optional arguments.

element

  • The current element.
  • Optional

index

  • The index of the current element.
  • Optional

array

  • The array that find is calling on.
  • Optional

thisArg

  • Object to use as this when executing callback.
  • Optional

Return Value

find() returns the value of the first element in the array that fulfills the provided testing function. If nothing fulfills the provided testing function, undefines is returned. Also find() does not mutate the original array.

Examples

Happy coding!

More Info!

JavaScript docs

array.slice()

JavaScript has many array methods that can help you solve a variety of problems. One of those methods is the slice() method. The slice() method returns a copy of an array that consists of elements that are selected by using two parameters. Both are optional. …

JS array.join()

JavaScript has many array methods that can help you solve a variety of problems. One of those methods is the join() method. The join() method creates and return a new string by joining all of the elements in an array.

Syntax

array.join([separator])

Parameters

separator

  • The separator is a string used to separate each pair of adjacent elements of the array. If excluded, the array elements are separated with a comma (“,”). If the separator is an empty string, all elements are joined without any characters in between them.
  • Optional

Return Value

The return value is a string with all array elements joined. If the array.length is 0, an empty string is returned. If the array contains only one element, the return value is the element without a separator.

Examples

Happy coding!

More Info!

JavaScript docs

array.includes()

JavaScript has many array methods that can help you solve a variety of problems. One of those methods is the includes() method. The includes() method determines whether an array includes a certain element, returning as a Boolean.

Syntax

array.includes(includes(findElement[, fromIndex])

Parameters

findElement
  • The element you are looking for in the array.
  • Required
fromIndex
  • The array index of the current element at which to begin searching for the findElement.
  • Optional

Return Value

The return value is a Boolean, which returns true if the value of the element was found, and false if it was not found.

Things to consider

  • If the fromIndex value is negative, the search starts from the index of array.length - fromIndex by asc.
  • If fromIndex is greater than or equal to the length of the array, false is returned. The array will not be searched.

Example

Happy coding!

More Info!

JavaScript docs

JS array.filter()

JavaScript has many array methods that can help you solve a variety of problems. One of those methods is the filter() method. The filter() method creates a new array with all of the elements that pass the test implemented by the provided function.

Syntax

array.filter(function(currentValue, index, array), thisValue)

Parameters

A function to…

Rails API

Getting Started

Using Rails as your API(Application Programming Interface) is a very popular choice. Rails provides a set of defaults that allows developers to get their app up and running quickly. To get started, run the following command:

rails new my_api --api -T

This will generate a new project. The API argument…

So, you graduated from a software engineering boot camp and don’t really know what to do next. I completely understand because I was in your shoes very recently. Hopefully this will help you know what to focus on next. I included many links to amazing articles that helped me.

Coding is Fun!

Algorithms and Data Structures

These…

Cat Whitmer

I am a Full Stack software engineer that enjoys problem solving and can't wait to learn more. Hard work and dedication shape my work ethic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store