<!--
Problem 1
Background:
India has a kite flying/fighting tradition. Each kite is tied to a thread that has ground glass rubbed onto it. This means one kite can cut another kite's thread, leaving the losing kite drifting down for someone to catch. When a kite fight starts, everyone shouts "Peche!", and when a kite wins, they shout "Ipo kaate!"
http://fighterkitecentral.com/pdfs/KitesinIndia.pdf
Problem statement:
We will assume that every 3rd kite that flies will end up starting a kite fight, every 5th kite ends up losing a kite fight. So print the numbers from 1 to 100; but for multiples of 3, print "Peche!" instead of the number; and for multiples of 5, print "Ipo kaate!"; and for numbers which are multiples of both 3 and 5, print "Peche! Ipo kaate!"
Examples:
Given there are 100 kites
When the game begins
Then the output should be
1 2 Peche! 4 Ipo kaate! Peche! 7 8
...and so on
-->
<button id="buttonclick">Get Answer</button>
<br/>
<span id="answer">
</span>
JavaScript
// helper function for output
document.getElementById("buttonclick").onclick = kiteGame;
function kiteGame() {
var answer = " ";
for (var i = 1; i <= 100; i += 1) {
if ((i % 3) == 0) {
answer += "Peche!";
}
if ((i % 5) == 0) {
answer += "Ipo kaate!";
}
if (((i % 3) != 0) && ((i % 5) != 0)) {
answer += i;
}
answer += " ";
}
document.getElementById("answer").innerHTML = answer;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.