DEV Community

loading...
Cover image for JS Fairy Tales #1 Three little variable pigs.

JS Fairy Tales #1 Three little variable pigs.

Pelayo Méndez
Barcelona based dev working mainly with JS and Python and occasionally in C++
Updated on ・3 min read

Once upon a time, in a lush forest lived three little variable pigs, happily and peacefully.

One day, however, the three little variable pigs heard of an evil mutant wolf sneaking around the forest. They decided to each build a house to protect themselves from the wolf.

The first little variable pig was called Var and he was very, very lazy. He did not want to spend a long time working so he built his house out of straw as fast as possible.

var house = "🏠"

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

One day, the wolf happened to pass by Var’s house. He knocked at the door and said, "Hey little piggy! Little piggy! Let me in or I'll blow your house down!"

The little variable pig would not open the door, so the big bad mutant wolf huffed, and puffed…

var house = "🏠"

function blow(uffff) {
    var house = uffff
}
blow("🏚️")

console.log(house)

"🏚️"
Enter fullscreen mode Exit fullscreen mode

…and blew the house down!

Var ran away to hide in his big brother Let’s house, which was built out of wood, a little more resistant than the straw house.

let house = "🏠"

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

The big bad mutant wolf followed the little variable pig smell all the way to the wooden house. He knocked at the door and said,
"Hey little piggies! Little piggies! Let me in or I'll blow your house down!"

The little variable pigs would not open the door, so the big bad mutant wolf huffed, and puffed…

let house = "🏠"

function blow(uffff) {
    var house = uffff
}
blow("🏚️")

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

…but the house was still standing. So, he huffed, and he puffed again even harder!

let house = "🏠"

function blow(uffff) {
    let house = uffff
}
blow("🏚️")

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

HE HUFFED, AND HE PUFFED…

let house = "🏠"

function blow(uffff) {
    house = uffff
}
blow("🏚️")

console.log(house)

"🏚️"
Enter fullscreen mode Exit fullscreen mode

…and blew the house down!

The two little variable pigs ran away to hide in their big brother Const’s house. Const was a very hard worker and had put a lot of effort into building his house. It was made of bricks and was very resistant indeed.

const house = "🏠"

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

The big bad mutant wolf followed the scent of the two little variable pigs all the way to the brick house. Without saying a word, he started to blow. He huffed, and he puffed.

const house = "🏠"

function blow(uffff) {
    var house = uffff
}
blow("🏚️")

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

And he huffed, and he puffed.

const house = "🏠"

function blow(uffff) {
    let house = uffff
}
blow("🏚️")

console.log(house)

"🏠"
Enter fullscreen mode Exit fullscreen mode

AND HE HUFFED, AND HE PUFFED!

const house = "🏠"

function blow(uffff) {
    house = uffff
}
soplar("🏚️")

"error"
Enter fullscreen mode Exit fullscreen mode

But the house was still standing, and the big bad mutant wolf felt out of breath. The three little variable pigs were felt very safe inside the house, but the wolf had another idea. He decided to climb onto the roof and enter the house through the chimney.

const house = "🏠"
let chimney = "🪵"
Enter fullscreen mode Exit fullscreen mode

But while he was climbing onto the roof the three little pigs started a fire and when the wolf came down the chimney...

const house = "🏠"
let chimney = "🪵"

chimney = "🔥"
chimney += "🐺"

console.log(chimney)

"🔥🐺"
Enter fullscreen mode Exit fullscreen mode

...he fell into the fire and leaped back up the chimney howling in pain. The wolf ran away and left the forest, never to return.

The three little variable pigs celebrated their victory with an amazing meal, and lived happily ever after, each one in their very own brick house.

Discussion (0)