{"id":3066,"date":"2021-10-09T13:54:55","date_gmt":"2021-10-09T13:54:55","guid":{"rendered":"https:\/\/rengga.dev\/blog\/?p=3066"},"modified":"2023-02-28T00:21:49","modified_gmt":"2023-02-28T00:21:49","slug":"js-tutorial-math-random-word-generator","status":"publish","type":"post","link":"https:\/\/rengga.dev\/blog\/js-tutorial-math-random-word-generator\/","title":{"rendered":"JS Tutorial &#8211; Math.random() Word Generator"},"content":{"rendered":"<p><span style=\"color: #ef3207;\"><a style=\"color: #ef3207;\" href=\"https:\/\/rengga.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Rengga Dev<\/strong><\/a> <\/span>&#8211; <code>Math.random()<\/code> is an API in JavaScript. It is a function that gives you a random number. The number returned will be between 0 (inclusive, as in, it\u2019s possible for an actual 0 to be returned) and 1 (exclusive, as in, it\u2019s not possible for an actual 1 to be returned).<\/p>\n<p>We replace the header with a randomly selected word from an array using\u00a0<code>Math.random<\/code>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">var word = words[Math.floor(Math.random() * words.length)] + \"!\";<\/pre>\n<p>This is a lot like the random image example \u2014 the perfect sort of practice for beginners!<\/p>\n<p><iframe style=\"width: 100%;\" title=\"Math.random() Word Generator\" src=\"https:\/\/codepen.io\/renggagumilar\/embed\/WNzaXVe?default-tab=result&amp;theme-id=dark\" height=\"400\" frameborder=\"no\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\"><br \/>\nSee the Pen <a href=\"https:\/\/codepen.io\/renggagumilar\/pen\/WNzaXVe\"><br \/>\nMath.random() Word Generator<\/a> by Rengga Gumilar (<a href=\"https:\/\/codepen.io\/renggagumilar\">@renggagumilar<\/a>)<br \/>\non <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<br \/>\n<\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rengga Dev &#8211; Math.random() is an API in JavaScript. It is a <a class=\"read-more\" href=\"https:\/\/rengga.dev\/blog\/js-tutorial-math-random-word-generator\/\" title=\"JS Tutorial &#8211; Math.random() Word Generator\" itemprop=\"url\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":3795,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[264,263,274,103,227,280],"newstopic":[],"class_list":{"0":"post-3066","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript","8":"tag-javascript-tutorial","9":"tag-js-tutorial","10":"tag-math-random","11":"tag-web-design","12":"tag-web-designer","13":"tag-word-generator"},"_links":{"self":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/comments?post=3066"}],"version-history":[{"count":1,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3066\/revisions"}],"predecessor-version":[{"id":3067,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3066\/revisions\/3067"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media\/3795"}],"wp:attachment":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media?parent=3066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/categories?post=3066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/tags?post=3066"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/newstopic?post=3066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}