Do you have a technical question that doesn't really fit a specific console? Want some general info on electronics, hacking, making cookies, etc? Here's the place to ask! Go nuts.
When the word is say: 5 letters long, then this arrLength/2 = 2.5, and based on your Holiday example, it should be 3.
2: after your first for loop, you reset omg to 1. What you really should do, is have an if statement to check if arrLength/2 = Math.ceil(arrLength/2); (i.e. is the word an odd number of letters), and omg-- if it is, otherwise leave OMG as it is.
Edit: Oh, I just reread the code, and realized that the way you were doing this it makes sense to set it to 1. but you will have to increment omg in the loop.
3. There is an off - by - one error in it as well, and more than likely you will get a index out of range exception.
Yea that's the error it was giving me. In the original text, the FRIEND example just ended with two, instead of making the two middle letters the same width. That was what I was doing with this code, so I just let it round up. The teacher said he wasn't gonna be too strict about how we handle words with an even number of characters.
HazmatB wrote:You can post the corrected one... I was going to let him try to figure it out.
Whatever.
Screw it.
I don't really know what this means... I Don't think there is anything wrong with giving it to him, but I just got the impression he didn't want it for free. I didn't mean to piss anyone off.