Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is supposed to be in jQuery!!! Can you make sure you've declared the temporary variable inside your for loop? I thought I did this

This is supposed to be in jQuery!!!

Can you make sure you've declared the temporary variable inside your for loop?

I thought I did this already but apparently, I haven't. Suggestions?

var toPigLatin = function(str) { if (!str.replace) { return 'ERROR: Expected a string!'; } return str.replace(/\b(\w)(\w+)\b/g, '$2-$1ay').toLowerCase(); }; // Iterate through each paragraph, call the toPigLatin function on it var $paragraphs = $('p'); for (var i = 0; i < $paragraphs.length; i++) { var element = $paragraphs[i]; // DOM node var $paragraph = $(element); $paragraph.html( $paragraph.html()); } $paragraphs.each(function(index, element) { var $paragraph = $(this); console.log(element === this); $paragraph.html( $paragraph.html()); });

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions