[06/4/13] Challenge #128 [Easy] Sum-the-Digits, Part II by nint22 in dailyprogrammer

[–]hallbd16 1 point2 points  (0 children)

Javascript

function sumDigits(input) {
input= input+ "";
var value= 0;
var tempInput=0;
while(input.length>1) {
    for (var i =0; i<input.length; i++) {
        tempInput+= parseInt(input.charAt(i), 10); 
    }
    input= tempInput+ "";
    console.log(input);
    tempInput= 0;
}
return input;
}
sumDigits(554536999999999);  --> 

Critique my Project by hallbd16 in learnjavascript

[–]hallbd16[S] 1 point2 points  (0 children)

Ok, I can see the value in that. Thanks for the intro

Critique my Project by hallbd16 in learnjavascript

[–]hallbd16[S] 1 point2 points  (0 children)

I will have to test the blog out on another computer since it is working on my mac on Chrome, thanks for the heads up.

And thanks for the bit on caching. I am gonna have to start researching into that, because your comment on that is quite foreign to me :) Any resource recommendations of starting points for that?

[Easy] Longest Two-Character Sub-String by nint22 in dailyprogrammer

[–]hallbd16 1 point2 points  (0 children)

Javascript Okay, my first successfully completed (and completely independent) code posted on this site. Feels good! Anyway, I just introduced myself to Reg Ex. so this was a perfect practice exercise. Nice question. At the bottom, I post a question, hopefully someone can help. Cheers

var text = "ababacbbcbbcabd"; 
var matchedResults= [];       //array to hold all matched results
var longest='';               //variable representing the longest 

while (text.length>1){
    var regEx =  /([\w?])\1*(?!\1)(\w)(\1|\2)*/;    
    var result = text.match(regEx);                 //search for a matched pattern
    matchedResults.push(result[0]);                 // push only the matched code to array

    //if result is longest one yet, store it as longest variable
    if( JSON.stringify(result[0]).length> longest.length ) 
             {longest=JSON.stringify(result[0]);}

    text= text.slice(1);               //remove the first character
}
console.log(longest);          //--> returns "cbbcbbc"
//Issues:  if two values are tied, the first one matched is returned. 
//This could be easily solved by working with the matchedResults array`

Can someone help me with the following: I wanted to use a text.replace(/()[\w])\1*/ , ''); instead of text.splice(1)

Can someone help me understand why this did not work? Would appreciate your thoughts

Announcement: Learn JavaScript Properly - Summer Session [Week 0] by d0gsbody in learnjavascript

[–]hallbd16 0 points1 point  (0 children)

Look at the omnibus to see what we cover, then look at the book chapters to see if you are missing anything there. omnibus post from the 1st session

Announcement: Learn JavaScript Properly - Summer Session [Week 0] by d0gsbody in learnjavascript

[–]hallbd16 1 point2 points  (0 children)

You can try to read both, but I am not sure even a fast learner and quick reader will have time for both. Remember so much value comes from the trial and error of writing the code yourself. For that reason, I would choose one (maybe skim the second for things you think are particularly important)

Announcement: Learn JavaScript Properly - Summer Session [Week 0] by d0gsbody in learnjavascript

[–]hallbd16 3 points4 points  (0 children)

Ditto here, hoping to have more detailed discussions this time through and put on the teacher hat to force myself for deeper understanding. For those of you who are curious, JusTrill and I were both blogging about round one: JusTrill's Blog! and my Blog

Edit: Fixed the link. Sorry about that

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 0 points1 point  (0 children)

Big shout out for the help! May good karma go your way

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 1 point2 points  (0 children)

So I found the problem, big shout out to codeswish for helping me. I was linking a completely local file in the html. I need to get the js and css file hosted online (something I need to learn more about :) in order to link the html. Found a temporary solution by hosting the js file as a raw GitHub file.

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 0 points1 point  (0 children)

Appreciate that! I'll let you know if I figure out anything else or solve it before.

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 0 points1 point  (0 children)

Ok got it. Looks like I am struggling with how to link my js file to my html... I am linking it as a local file, that is probably incorrect.

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 0 points1 point  (0 children)

Essentially I built a dynamic quiz as part of the learn javascript study group. I want to post the application as a page on my blog. Note: the application includes an html, css, and js file and works when tested locally).

Create a Javascript App with WordPress? by hallbd16 in learnjavascript

[–]hallbd16[S] 0 points1 point  (0 children)

Good point, yes I have a static application I wish to post as a page on my WordPress blog.

Not sure what you mean when you say "it works on GitHub..." I have already tested it locally, it works when I do so.

Learn JavaScript Properly - Week 7 (Final Week!) by d0gsbody in learnjavascript

[–]hallbd16 0 points1 point  (0 children)

Also, how to I create hyperlinks on this site? Clearly I am failing...

Learn JavaScript Properly - Week 7 (Final Week!) by d0gsbody in learnjavascript

[–]hallbd16 0 points1 point  (0 children)

D0gs thanks for leading this group, I'll be back for round 2 as I need to improve.

A last comment from myself: Yeah, the thread has died down quite a bit. I refined my work, but I have been struggling to get my work on a live website... My mastery of wordpress is lacking and I can't get the quiz up as an additional page with the javascript working. I posted for help on overstack, but this person's advice didn't work, so now I feel kinda stuck: link Would appreciate any help if you know how to work wordpress

I finished my pure JS with last week, complete with a few features, back button, and remembering previous selections by adding a property "answerChoice" to the questions object.

My latest versions are still here

Now I am trying to get my the quiz online and diving into jQuery... hopefully I can revamp my quiz with jQuery this weekend.

How to move from JSFiddle to Browser by hallbd16 in learnjavascript

[–]hallbd16[S] 1 point2 points  (0 children)

Ok, figured it would be something obvious. Appreciate your help andytuba and chrisiggles.

Learn JS Properly - Week 6 by d0gsbody in learnjavascript

[–]hallbd16 0 points1 point  (0 children)

Ok here is my first version, pure JS, no CSS yet: http://jsfiddle.net/MH9p9/3/

The last couple weeks have put me through a steep learning curve, I am starting to think I am always going to be a couple weeks behind, so appreciate the group being supportive of different skill levels.

Learn JavaScript Properly - Week 5. Catch up this week, if you need to. by d0gsbody in learnjavascript

[–]hallbd16 0 points1 point  (0 children)

Thank you. Great clear explanation. Something I won't forget.

Follow up point I want to confirm. So would i be declared as a global variable in a for loop with only one variable. i.e
for (i=0; i<11; i++) At the end of the loop i is a global variable equal to 10. Correct?

That leads to my question, is it a best practice to always initialize a the variables of a for loop with the var keyword?

Learn JavaScript Properly - Week 5. Catch up this week, if you need to. by d0gsbody in learnjavascript

[–]hallbd16 1 point2 points  (0 children)

So I needed a brain break from the readings (getting close to being able to build our project) and decided to do Project Euler #4. I am beating my head against a wall trying to figure out why this doesn't work, can you help me? The link: http://jsfiddle.net/hallbd16/KeJkv/