Javascript Arrays for Beginners (2023)

Arrays hold values.

An array is an ordered list of values.

Arrays are 0-based, in that the first value is 0, not 1 in terms of its position.

A JavaScript array has the following characteristics:

  1. First, an array can hold values of mixed types. For example, you can have an array that stores elements with the types number, string, boolean, and null.
  2. Second, the size of an array is dynamic and auto-growing. In other words, you don’t need to specify the array size up front.

source

W3schools describes an array as a “special variable, which can hold more than one value”.

An array can hold many values under a single name, and you can access the values by referring to an index number.

arrays w3schools

source

Creating & Fetching JavaScript arrays

JavaScript provides you with two ways to create an array. 

It is a common practice to declare arrays with the const keyword.

Image source

You can also use the following code to create a new array:

let values = new Array();

or

let values = [item1,item2,...]

Once you’ve created your array, you can print the values to the console.log with the code:

console.log(values);



With “values” being the name of the array.

You can call “values.length” to get the length of the array

console.log(values.length);

Again, in the above code “values” is the name of the array.

You can define and name an array, and then “push” values into it later:

The above code will add a single value of 5 to the array named “values”.

console.log(values[1]); will print the second value – 7

console.log(values[0]); will print the first value – 5

In summary – to create an array, it’s generally best to use the “const” keyword, or the “new” keyword.

Adding & Changing Stuff Within Arrays

Below, the array name is used,and the variable number to update, the first variable.

You can try it yourself on the w3 schools website.

Accessing Arrays

You access an array element by referring to the index number:

accessing arrays

You can also loop through arrays

Adding a New Sub-Category in M2

Main menu thing

Got to Catalog – Categories

Pick a store (leave on all store views put pick a store from the folders below)

Pick a folder –> click “Add Subcategory”

Include in menus – Off canvas & All Sports

Enable category – No

  • INCLUDE IN MAIN MENU – NO (unless a main sport top-category page e.g. /cricket or football main page
  • Category Description Placement – Show at bottom

  • Category Name – Add H1

Leave menu settings

  • CONTENT

Add thumbnail image if you have one

Description – Edit with Page Builder – > Apply Template -> Search for “product” -> Use Product Description

APPLY

Click cog icon

Put <p> </p> tags and paste in description for page

SAVE

close full screen with two arrows in top right.

  • ADD CMS Block

Select Megamenu Golf (2nd one!)

Display settings – Select Price

  • SEARCH ENGINE OPTIMISATION

Add URL, meta title and meta desc.

URL doesn’t need .HTML at the end.

— Don’t enable foreign sites! and put in clickup

Javascript Functions for Beginners

A function is a piece of code, that can be reused.

It’s similar to a variable but doesn’t hold a value like a variable does. So it’s not that much like a variable, but kind of is.

Screenshots are from the brilliant Javascript Course on Udemy here

The code on lines 16 and 17 shown in the image above, creates the function. It is named “logger”.

the shorter code logger(); is used to/for “invoke”, “running”, or “calling” the function.

Function Declerations Vs Expressions

Function Declerations

When you create a function with a name, then it is a function decleration.

Function statements, declare a function. A declared function can be used later when it is “invoked” or “called”.

Function declerations must start with “function”.

For example:

function mma() {

return 8;

}

The functioned mma is declared. to invoke it use the code mma();

You can call function declerations, above the code that creates it.

Function Expressions (good article here)

A JavaScript function can also be defined using an expression.

A function expression can be stored in a variable:

Image source

Function expressions are invoked to avoid polluting the global scope. Instead of your program being aware of many different functions, when you keep them anonymous, they are used and forgotten immediately.

To summarize, function declarations are utilized when you desire to establish a function in the global scope that can be accessed anywhere in your code. On the other hand, function expressions are employed to confine the accessibility of the function, reduce the weight of the global scope, and maintain a neat syntax.

JavaScript Arrow Function

Arrow functions have shorter syntax

They are best suited to non-method functions

source

Functions Calling Other Functions

An example, might be a function that cuts up fruit pieces, and then sends the result to a function that blends it into a smoothie.

The start function used above, will print out “I am first bo! 222222!!!”

Functions Summary

A function is like a procedure. It has tasks and calculates a value.

A function requires input and must return an output.

Functions need to be defined with the word “function” and brackets ()

Brackets can also be called paranthesies, and the input is sometimes called “arguments” or “parameters”.

Image source

Image Source

Finding & Fixing 404s with Screaming Frog [2024]

Export the 404 Inlinks Report into Excel

The best report in Screaming Frog to see the source and destination of all 404s – is to go to Bulk Export at the top menu:

And then Response Codes – Client Error Inlinks

In the Exported Excel Sheet:

Copy the “destination” column

Paste into a new sheet/tab – In Column B

Remove duplicates

Back in the first sheet – Paste “Source”, into column D to the right of “destination” in first tab/sheet


In the second sheet –
Do a vlookup in the second sheet/tab – to import a source URL to each unique “destination” URL
Add the word “source” to cell C1 in the second sheet

I think you have to click the file name to download the example sheet below:

Sheet / Tab 1 should look like this:

The Second Sheet / Tab should look like this:

The Lookup Value in Cell C2, in the sheet above is:

=VLOOKUP(Sheet1!B2,’1 – Client Error (4xx) Inlinks’!C:D,2,0)

Just double click / drag it down to complete the lookup

You can add more lookups and columns to provide more details about the link location.

Just copy and paste values on the last Vlookup.

Paste another column like “Anchor” into column D on the first Tab

Paste the vlookup into the adjacent column

“0” means nothing found – i.e. no anchor text etc

Update –

404s found in the Navigation or “Aside” tend to be site-wide, so you can find one instance of this and update the 404 and Bob’s your uncle.

If a 404 is within the page content/copy however, they are possibly unique and need fixing individually. So take a look the Content 404s separately. They probably only have 1 source URL so no need to faff with vlookups etc.

Excel – Find Cells that contain 2 Specific Words

If you are for example, searching an e-commerce site crawl or download for football goals…

If you want to identify cells that contain, for example “football” and “goal”, you can use the formula:

With the URLs in column A, in column B add the formula:

=AND(ISNUMBER(SEARCH("football",A2)),ISNUMBER(SEARCH("goal",A2)))

To find cells that contain “football” OR “goal”, use:

=AND(ISNUMBER(SEARCH("football",A2)),ISNUMBER(SEARCH("goal",A2)))


Bulk checking Canonical URLs & Hreflang Tags for SEO on an eCommerce Store (With Screaming Frog)

TLDR – Easiest way to check hreflang is to just go to reports > Hreflang > non200 Hreflang URLs:

Filter “Source” column to your current domain and then you should see all the hreflang that 300 or 404.

  • However – you ideally want to get all of your indexable, 200 status code URLs – to have the relevant hreflang tags.
  • So first find all the indexable, 200, URLs with exact-match canonicals
  • Then check the hreflang on these only
  • Get all the URLs that 200 and are indexable from “internal_all” report
  • Paste in list mode, all of these URLs – check hreflang tab
  • Perform a Crawl Analysis
  • Check The overview panel

hreflang screaming Frog
  • Order the Hreflang tab by occurrences to double check tall URLs have at least 1 hreflang

Checklist here – https://docs.google.com/spreadsheets/d/1IHRZNFravVKaZ5T9uOEOg_zQ5ee8dHcRP8m92vkn4KY/edit#gid=0

Configuration – spider – crawl and store Hreflang

Find URLs that should have a hreflang tag – Indexable URLs

  • Crawl the website with Screaming Frog – in configuration crawl and store Hreflang
  • Download the “internal” report on first tab
  • Filter relevant columns to find all URLs that return 200 (Status Code), are indexable (Indexability)

Check Canonical URLs are Correct and Indexable

  • From the internal Report – filter status code to 200 only and Indexable
  • Paste the filtered columns into a new tab/sheet and delete irrelevant columns so you just have URL and Canonical columns
  • Use =Exact formula to find all URLs that match the canonical URL
  • For canonical checks – filter to “FALSE” and see which URLs don’t have self ref canonicals

Back in Internal – Original Spreadsheet

  • unfilter the internal report.
  • Filter to show all the canonical URLs. Canonical Column – filter – untick “blanks”
  • Copy and paste into Screaming Frog , list mode – check status code of all these canonical URLs

  • For Hreflang – Filter Canonical URL column to “true”
  • You should be left with all URLs that are indexable (and should therefore have hreflang if an international site) – i.e. 200 status codes and URLs that exactly match canonical URLs.

Hreflang Checks

For the indexable URLs found above, check hreflang using:

https://technicalseo.com/tools/hreflang/

  • Go to screaming frog GUI – and the Hreflang Window

Order by Occurrences – check if any URLs have less hreflang then they should have

  • Check all the reports in the drop down menu on the left

Non-200 Hreflang URLs – URLs within the rel=”alternate” markup that don’t result in a 200 status code

Download the non-200 hreflang report – by going to the “hreflang” tab in Screaming Frog.

Delete all the columns except those containing the actual hreflang URLs

Then in the column adjacent to all the hreflang URLs add the formula:
=INDEX($A$1:$G$126,CEILING(ROW()/7, 1),MOD(ROW()-1,7)+1)

The formula above would be used if the hreflang URLs are in columns A to G, and the last row that is populated in number 126.
You’ll also need to update the number 7 in the formula – for example if you have 5 columns of hreflang URLs, then change 7 to 5.

Drag this formula down until you start seeing #REF! errors, indicating you’ve covered all the data in your original columns

  • You should now have all the hreflang URLs listed in the non-200 hreflang report
  • To find the specific URLs that are non-200 – paste the last column containing all the URLs, into screaming frog in “List” mode

Export the List mode ‘crawl’ from Screaming Frog and filter by status code

  • Unlinked Hreflang URLS – Page sthat conain one or more hrelgang tag / URL that’s only linked to by a hreflang tag and not in the actual webpages

  • Missing Return Links – Hreflang should be recipricol.
  • Inconsistent Language & Region Return Links – This filter includes URLs with inconsistent language and regional return links to them. This is where a return link has a different language or regional value than the URL is referencing itself
  • Non Canonical Return Links – URLs with non canonical hreflang return links. Hreflang should only include canonical versions of URLs.
  • Noindex Return Links – Return links which have a ‘noindex’ meta tag. All pages within a set should be indexable, 
  • Incorrect Language & Region Codes – This simply verifies the language (in ISO 639-1 format) and optional regional (in ISO 3166-1 Alpha 2 format) code values are valid
  • Missing Self Reference – URLs missing their own self referencing rel=”alternate” hreflang annotation. It was previously a requirement to have a self-referencing hreflang, but Google has updated their guidelines to say this is optional. It is however good practice and often easier to include a self referencing attribute.
  • Not Using Canonical – URLs not using the canonical URL on the page, in it’s own hreflang annotation. Hreflang should only include canonical versions of URLs.
  • Missing – URLs missing an hreflang attribute completely. These might be valid of course, if there aren’t multiple versions of a page.
  • Outside <head> – Pages with an hreflang link element that is outside of the head element in the HTML. The hreflang link element should be within the head element, or search engines will ignore it.

Official documentation from Screaming Frog here.

You can also use this Google sheet to check hreflang further