₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,018 members, 8,419,962 topics. Date: Thursday, 04 June 2026 at 08:21 AM

Toggle theme

Please I Need Help - Evaluating A Javascript Code Line By Line - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPlease I Need Help - Evaluating A Javascript Code Line By Line (775 Views)

1 Reply

Please I Need Help - Evaluating A Javascript Code Line By Line by Cybergenius(op): 5:30pm On Oct 26, 2014
I have this html/javascript +jquery code, which is meant to
compile my code, but i dont know how to read the
javascript as a code.

//the code
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script async>
window["logerrors"] = function(){

var script = $("script#val"wink.text().replace(/[\n]/ig,"};"wink;
var reps = script.replace(/};/ig,"~"wink;
var eachLine = reps.split("~"wink;
var errors ="";
var err = [];

for($i=0;$i<eachLine.length;$i++){
try{
new Function(eachLine[$i])();
err.push("no"wink;
continue;
} catch(e){
errors += "Scope Number: "+ Number($i+1) +"<br>"+e +
"<br><span style='color:red;white-space: pre'>"+eachLine
[$i]+"</span><hr>";
err.push("yes"wink;
continue;
}
}

if(err.indexOf("yes"wink > -1){
$("body"wink.html(errors);
} else{
return true;
}

}
</script>
</head>
<body onLoad="logerrors()">
<script id="val">
var i = jQuery;
while(!i){
var i = jQuery;
}
phrompt(i.fn.jquery);
ro(q);

//the while loop is an example, the code reads it as "while(!i){"
</script>
</body>
</html>
Re: Please I Need Help - Evaluating A Javascript Code Line By Line by Cybergenius(op): 5:33pm On Oct 26, 2014
The above code is meant to compile my code in a script tag
with an id of "#val", if i read the code by line, it wont work out, cause it would also read "while(!i){" as a code on its own, my question is - How do i read that particular block of code

while(!i){
var i = jQuery;
}


read this as whole and not by line
Re: Please I Need Help - Evaluating A Javascript Code Line By Line by bot101(m): 12:41am On Oct 27, 2014
from what i can see here, i believe you have commited some syntax errors. look for a missing " and ; and close/delete appropriately. your replace() is also missing a second parameter.
1 Reply

Adding Validation To Javascript CodeWhat Could Be Wrong With This Javascript CodeJavascript Code Autocomplete In Webpage234

Revolutionary Social Media Experience, Orbi; Twitter For Voice Notes LaunchesSoftware Architecture - Don't Ignore The Big PicturePlease I Need An Original Eassy Browsing Cyber Cafe Timer