PDA

View Full Version : say("HELLO");



magicyte
09-01-2008, 10:39 PM
A simple say("hi") reply("hi to you") type of script. Note that it is JavaScript.


function say(word)
{
if(word == "S---") reply("How dare you use such word!");
else if(word == "F---") reply("You could just say \"Whoops!\"!");
else if(word == "Maam, you dropped that anvil on your toe.") say("S---");
else if(word == "Did you remeber to mail the gas bill?") say("F---");
}

function reply(word)
{
alert(word);
}

:D:p:rolleyes:

-magicyte

mburt
09-01-2008, 10:51 PM
More efficient, hehe :p:


<script type="text/javascript">
var words = {
someword: "someword reply",
hello: "how do you do",
"how are you doing": "test"
}, say = function(word) {
for (var x in words) {
if (word.toLowerCase() == x) {
reply(words[x]);
};
};
}, reply = function(word) {
alert(word);
};
say("Hello");
</script>

magicyte
09-01-2008, 10:54 PM
Ha!

-magicyte

Twey
09-02-2008, 12:05 AM
Actually that's less efficient (but neater, admittedly). for..in loops are very slow. Neater still, no guarantee of efficiency (but got to be better than the for..in):
var say = (function(words, v, say) {
return say = function(sentence) {
(v = words[(alert(sentence), sentence).toLowerCase()]) && say(v);
};
})({
"s---" : "How dare you use such language!",
"f---" : 'You could just say "Whoops!"',
"ma'am, you dropped that anvil on your toe." : "S---",
"did you remember to mail the gas bill?" : "F---"
});Aren't you from America, Magicyte? Your English seems somewhat non-native...

magicyte
09-02-2008, 12:54 AM
Aren't you from America, Magicyte? Your English seems somewhat non-native...

Really? This is how everybody talks in America. How does it seem "non-native"?

-magicyte

mburt
09-02-2008, 01:48 AM
Wow that was really stupid of me :/ ... I'm not thinking right. I didn't think of the simple fact that you could call the value of the array with the argument in the function haha.

Twey
09-02-2008, 01:50 AM
Things like "how dare you use such word" remind me of Engrish :)

mburt
09-02-2008, 01:53 AM
I think that's pretty commonly used though... But my perspective probably isn't the greatest, considering all the different accents that are around here. :p

Twey
09-02-2008, 03:40 AM
But 'word' is a singular countable, and 'such' expects a plural or uncountable.

Trinithis
09-02-2008, 05:23 AM
I would say, "How dare you use such a word."

Twey
09-02-2008, 07:11 AM
Ah, yes, the article works too, of course.

magicyte
09-02-2008, 09:17 PM
Yeah. In America, people don't care about proper grammar too much (that is the majority). I am a spell freak, but not so much of a proper pronoun whatev freak. Mostly everybody in the U.S. (that I know of) talks slang. We even use two negatives to make a right!! (ex. Are you not not going to eat that? (thus meaning "Are you going to eat that?")) Of course, in where I live, everybody says "y'all", but I stick to "you guys". But, yeah, we have people that say "y'all 'd've" (meaning "you all would have" - it is short and easier to say). In fact, a bunch of people contrapt would and 've instead of would have. Easily saying "wood-uv".

Anyway, I can type english correctly, and I do speak it. I also know a bit of spanish, but that is a whole other subject.

Basically what I'm saying is: in America, we TALK slang, but we write CORRECTLY. So if I'm on this networking site, chances are I will probably talk slang.

-magicyte