aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Unable to understand a code in a function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Unable to understand a code in a function?" Watch "Unable to understand a code in a function?" New topic
Author

Unable to understand a code in a function?

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

function checkSpecial(val){

var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
for (var i = 0; i < val.length; i++) {
if (iChars.indexOf(val.charAt(i)) != -1) {
return true;
}


Unable to understand a code in a function.


http://www.lifesbizzare.blogspot.com || OCJP:81%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

This is not Java code. Var is not a Java class nor primitive, it's missing a return statement and a char can't have a negative value.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Please take the time to choose an appropriate forum for your posts. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Start breaking it down. What do you think each line does?
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

A function named checkSpecial. Is val a variable(if yes what sort of variable)


Ichars is also a variable which is assigned some special charectes...

But iam not getting the idea why is this function used.Is there any specific reason to it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to understand a code in a function?