Skip to content
Advertisement

Tag: for-loop

Comparing length of strings in an array?

Hi I’m trying to compare the length of each word in a sentence. I converted this sentence into an array but then I’m lost in my codes. I tried 2 methods – for loop and reduce(), but neither worked. What happened in my code? Reduce() => This one gave me undefined when I try to run the function. I gathered

Javascritpt – Looping through an array

So i just started learning js and i can’t solve this excercise: Create a file named looping-through-arrays.js. In that file, define a variable named pets that references this array: [‘cat’, ‘dog’, ‘rat’] Create a for loop that changes each string in the array so that they are plural. You will use a statement like this inside the for loop: pets[i]

Append cachebreaker to filenames of all images of a type

I’m able to identify all images of type (SVG) and append a cachebreaking date string in the console log. I’ve been looking at this solution, but it’s only for individual filenames, not multiple images: https://stackoverflow.com/a/1077051/3787666 Any help appreciated. Answer Okay, here’s how it works, adding a cachebreaker to every SVG image in a page: Caveat is that this forces the

Advertisement