Skip to content

Instantly share code, notes, and snippets.

@dmastag
Created May 28, 2018 00:26
Show Gist options
  • Save dmastag/ddfc30ca80720e29ae3da25b67b4b670 to your computer and use it in GitHub Desktop.
Save dmastag/ddfc30ca80720e29ae3da25b67b4b670 to your computer and use it in GitHub Desktop.
// source http://jsbin.com
<!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">
"use strict";
var dataAwal = "kukuku cupu-cupu";
var yangDiganti = "u";
var regexp = new RegExp(yangDiganti, "g");
var digantiJadi = "o";
var hasil = dataAwal.replace(regexp, digantiJadi);
console.log(dataAwal);
console.log(hasil);
</script>
<script id="jsbin-source-javascript" type="text/javascript">const dataAwal = "kukuku cupu-cupu";
const yangDiganti = "u";
const regexp = new RegExp(yangDiganti, "g");
const digantiJadi = "o";
const hasil = dataAwal.replace(regexp,digantiJadi);
console.log(dataAwal)
console.log(hasil)
</script></body>
</html>
"use strict";
var dataAwal = "kukuku cupu-cupu";
var yangDiganti = "u";
var regexp = new RegExp(yangDiganti, "g");
var digantiJadi = "o";
var hasil = dataAwal.replace(regexp, digantiJadi);
console.log(dataAwal);
console.log(hasil);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment