Skip to main content
blog title image

2 minute read - slogans JavaScript

Hack the JavaScript Evil Tester Sloganizer to Generate Random New Year's Resolutions

Jan 2, 2017

I wrote a blog post for the new year:

  • </2016/12/happy-testing-new-year-for-2017.html>

And in there I noted that if you go off to the Evil Tester Sloganizer
and type this code

for(var x=0;x<100;x++){
console.log("-" + process_sentence(sentences[30]));}

Then you’ll get a bunch of New Year’s Resolutions printed out to the console e.g. :

-I will try to pursue this risk further
-I resolve to scrutinize requirements
-I resolve to scrutinize ambiguity
-I think I might just exploit this defect further
-I will follow this risk further
-I think I might just provide alternative alternatives
-I will try to question more requirements
-I will learn to test effectively
-I resolved to scrutinize ambiguity
-I think I might just test the lifeblood out of this system
-I resolved to test the life out of this system
etc.

But what if, we want them to appear in the sloganizer itself?

Well, if instead of writing the console I wrote to the DOM, what would happen?

document.getElementById("slogan").innerHTML=process_sentence(sentences[30])

Ooh…

And what if we wanted a new resolution every second? Because we are such a flibbertigibbet that we can’t stick to anything?

Well, we’ve got you covered there too:

resolutionBot = setInterval(
function(){
document.getElementById("slogan").innerHTML=process_sentence(sentences[30])
}, 1000)

And when we are done, remember to stop it:

clearInterval(resolutionBot)

Exercise: As an exercise to the reader, the code above changes the DOM but doesn’t update the application status, so if you found a good slogan you couldn’t click Tweet This and have the system tweet it for you. See if you can change slogan to the result of process_sentence(sentences[30]) such that you could Tweet This if you wanted to.