Skip to content

Instantly share code, notes, and snippets.

View putrairawan992's full-sized avatar

putra992 putrairawan992

  • 21:58 (UTC +07:00)
View GitHub Profile
async function run() {
let prefix = '(2)'
console.log(prefix + ' with await')
await asyncWithAwait(prefix)
console.log(prefix + ' with promise')
asyncWithPromise(prefix).then(_ => console.log(prefix + ' after all'))
}
run()
async function run() {
let prefix = '(1)'
console.log(prefix + ' with await')
asyncWithAwait(prefix)
console.log(prefix + ' with promise')
asyncWithPromise(prefix)
console.log(prefix + ' after all')
}
run()
import React, { useState, useEffect } from "react";
export default props => {
console.log("componentWillMount");
console.log("componentWillReceiveProps", props);
const [x, setX] = useState(0);
const [y, setY] = useState(0);
const [moveCount, setMoveCount] = useState(0);
const [cross, setCross] = useState(0);
const mouseMoveHandler = event => {
setX(event.clientX);
@putrairawan992
putrairawan992 / Inspector
Created January 3, 2019 02:27
Fix the bugs in the following HTML code.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Company page</title>
</head>
<body>
<p>Welcome! Here you can find following things:</p>
<ol>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Modal Dialog</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
@putrairawan992
putrairawan992 / Avatar
Created January 2, 2019 15:53
Fix the bugs in the following HTML code.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Avatar</title>
<style>
.avatar {
border-style: solid;
border-width: 2px;
border-radius: 50%;
@putrairawan992
putrairawan992 / Loop
Created January 2, 2019 15:08
Function appendChildren should add a new child div to each existing div. New divs should be decorated by calling decorateDiv. For example, after appendChildren is executed, the following divs:
function appendChildren(decorateDivFunction) {
var allDivs = document.getElementsByTagName("div");
for (var i = 0, len = allDivs.length; i < len; i++) {
var newDiv = document.createElement("div");
decorateDivFunction(newDiv);
allDivs[i].appendChild(newDiv);
}
}
// Example case.