In my Open Source Development 600 course, I was assigned to work on the bugs 41284 for on Processing.js (tickets 270 -275) which were implementation of simple string functions. I needed to review my javascript which I took in first year and learned the prof. programming style. Here were my code for the first release 0.1.
Convert all characters of a string into a upper case and return the string:
function stringToUpperCase(string str)
{
var strUpperCase = str.touppercase();
return strUpperCase;
}
Or convert all characters of a string to lower case and return the string:
function stringToLowerCase(string str)
{
var strLowerCase = str.tolowercase();
return strLowerCase;
}
To find part of string using substring:
function StringSubstring(string str, int beginIndex, int endIndex)
{
var stringSub;
if(endIndex >0)
stringSub = str.substring(int beginIndex, int endIndex);
else
stringSub = str.substring(int beginIndex)
return stringSub;
}
To find total characters in a string
function strLength(string str){
return str.length();
}
Find a substring within a string and return the first occurrence otherwise return -1
function stringIndexOf(string str, string subStr){
int p1 = str.indexIf(subStr);
if(p1==-1)
return -1;
else
return p1;
}
Get a character in a string at a specific index
function stringCharAt(string str, int strIndex){
if(strIndex > -1 && strIndex < c1 =" str.charAt(strIndex);" href="https://processing-js.lighthouseapp.com/projects/41284/project-workflow">repos and got a public key. Now I need to add my new js file to the branches and test them.
Subscribe to:
Post Comments (Atom)
is it possible to put all those tickets into one? because all of them are working for string.
ReplyDeletebtw, you code doesn't look good for me. you may need a some changes to pass the review.
for example, if a function have three parameters but it is actually using two, you can say
if (arguments.length === 2) {
// code...
}
hurry up!