www.webdeveloper.com
Results 1 to 7 of 7

Thread: Help with functions 8

  1. #1
    Join Date
    Nov 2013
    Posts
    27

    Help with functions 8

    Hey, please can someone help me figure out a code for this function.

    Name of function and its parameter
    scores(web,pattern)

    Description
    returns an array of scores (each score is the number of times that pattern occurs in a content part in the arrayweb)

  2. #2
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    255
    Again not sure if this is what you're looking for:

    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    	<title> Untitled </title>
    	<meta charset="utf-8">
    	<script>
    		var myarray = [
    			"Bionoid is my friend. I don't want Bionoid to get angry on me.",
    			"Bionoid is from South Africa. Bionoid is a nice name. Bionoid is my friend.",
    			"Bionoid writes nice codes."
    		];
    		
    		function scores(array,pattern)
    		{
    			var re = new RegExp(pattern,"gi");
    			var numScored = [];
    			
    			function getNumOfScores(value, index, array)
    			{
    				return value.match(re).length;
    			}
    			
    			numScored = array.map(getNumOfScores);
    			return numScored;
    		}
    		
    		var scArray = scores(myarray,"bionoid");
    		
    		for (var index in scArray)
    		{
    			document.write("Number of pattern scores at element position " + index + " is: " +
    						   scArray[index] + "<br />");
    		}
    	</script>
    </head>
    <body>
    </body>
    </html>
    Hope my friend Bionoid won't be mad on me because of this little joke

    Good Night!

  3. #3
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    795
    bionoid blushes.
    bionoid gives tech_soul8 a hug.

    You made my day, thank you :'D
    JavaScript: Learn | Validate | Compact | bionoid

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Well thats a homework question if I ever saw one, you should have posted something of what you have tried yourself and people generally don't mind giving help but to post a homework question then ask for someone to do your homework is a bit cheeky
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,377
    Quote Originally Posted by \\.\ View Post
    Well thats a homework question if I ever saw one, you should have posted something of what you have tried yourself and people generally don't mind giving help but to post a homework question then ask for someone to do your homework is a bit cheeky
    Yes, I agree.
    And he/she has asked for the same kind of help without any attempts in a number of other posts. (Note thread titles).

  6. #6
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    255
    Quote Originally Posted by \\.\ View Post
    Well thats a homework question if I ever saw one, you should have posted something of what you have tried yourself and people generally don't mind giving help but to post a homework question then ask for someone to do your homework is a bit cheeky
    Agree on that too! Generally I don't support helping to someone who's too lazy to try to work things out for him/her self or just looking for someone else to do the job instead of him/her (especially if that someone is running a web site) but... there was some tries made by CodeGuru in several threads so...
    Last edited by tech_soul8; 11-07-2013 at 02:42 AM.

  7. #7
    Join Date
    Nov 2013
    Posts
    27
    Quote Originally Posted by tech_soul8 View Post
    Agree on that too! Generally I don't support helping to someone who's too lazy to try to work things out for him/her self or just looking for someone else to do the job instead of him/her (especially if that someone is running a web site) but... there was some tries made by CodeGuru in several threads so...
    Yesssss there were some tries. I've been working on it and I will post what I've done so far. I apologise if I made it look like I was giving people my homework to do. Btw tech_soul8 and bionoid are top lads!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles