Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fizzbuzz code javascript #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Webinar01/Fizzbuzz code
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> FIZZ BUZZ </title>
</head>
<body>
<ul id = "fizzbuzz">

</ul>
<script>
let fblist = document.getElementById('fizzbuzz')
let starttime = new Date().getTime()
let listData = ""
for(let i=1;i<1000;i++){
let item = "";
// instead of using modulo using counter and checking it as 3 or 5 or 15 is
//less time consuming
if(i%3==0) item += "fizz "
if(i%5==0) item += "buzz "
if(item=="") item += i
// this ia quite time consuming
// fblist.innerHTML += "<li>"+item+"</li>"
listData += "<li>" + item +"</li>"
}
fblist.innerHTML = listData
let endtime = new Date().getTime()
console.log(endtime-starttime)
</script>
</body>
</html>