Skip to content

Instantly share code, notes, and snippets.

@MirzaChilman
Created September 26, 2018 08:25
Show Gist options
  • Save MirzaChilman/ecb6cf54d106ac372fc27d311119d61e to your computer and use it in GitHub Desktop.
Save MirzaChilman/ecb6cf54d106ac372fc27d311119d61e to your computer and use it in GitHub Desktop.
Latihan test kerja 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function test(i) {
const text1 = 'Codility'
const text2 = 'Test'
const text3 = 'Coders'
for(let n=1; n< i;n++){
if(n % 5 === 0 && n % 3 === 0 && n % 2 === 0 ){
console.log(text1+text2+text3)
}else if(n % 5 === 0 && n % 3 === 0){
console.log(text2+text3)
}else if(n%3 === 0 && n%2 === 0){
console.log(text1+text2)
}else if(n%2 === 0 && n%5 === 0){
console.log(text1+text3)
}else if(n % 2 === 0){
console.log(text1)
}else if(n % 3 === 0){
console.log(text2)
}else if(n % 5 === 0){
console.log(text3)
}else {
console.log(n)
}
}
}
test(24)
</script>
<script id="jsbin-source-javascript" type="text/javascript">function test(i) {
const text1 = 'Codility'
const text2 = 'Test'
const text3 = 'Coders'
for(let n=1; n< i;n++){
if(n % 5 === 0 && n % 3 === 0 && n % 2 === 0 ){
console.log(text1+text2+text3)
}else if(n % 5 === 0 && n % 3 === 0){
console.log(text2+text3)
}else if(n%3 === 0 && n%2 === 0){
console.log(text1+text2)
}else if(n%2 === 0 && n%5 === 0){
console.log(text1+text3)
}else if(n % 2 === 0){
console.log(text1)
}else if(n % 3 === 0){
console.log(text2)
}else if(n % 5 === 0){
console.log(text3)
}else {
console.log(n)
}
}
}
test(24)
</script></body>
</html>
function test(i) {
const text1 = 'Codility'
const text2 = 'Test'
const text3 = 'Coders'
for(let n=1; n< i;n++){
if(n % 5 === 0 && n % 3 === 0 && n % 2 === 0 ){
console.log(text1+text2+text3)
}else if(n % 5 === 0 && n % 3 === 0){
console.log(text2+text3)
}else if(n%3 === 0 && n%2 === 0){
console.log(text1+text2)
}else if(n%2 === 0 && n%5 === 0){
console.log(text1+text3)
}else if(n % 2 === 0){
console.log(text1)
}else if(n % 3 === 0){
console.log(text2)
}else if(n % 5 === 0){
console.log(text3)
}else {
console.log(n)
}
}
}
test(24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment