Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started