- var printFiftyNumbers() {
- var text = "";
- var i;
- for(i=0; i <= 50; i++) {
- text += i + "<br>";
- }
- document.getElementById("demo").innerHTML = text;
- }
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts
Thursday, April 23, 2020
Program to print numbers from 0 to 50 in JavaScript
Convert Image to Base64 array in JavaScript
It is very easy to convert image to Base64 String in JavaScript.
To convert you need jQuery library to your html.
Just pass the image to this below imageFileAsBase64(). Get the Base64 value for the image in imagebase64 variable.
- var imagebase64 = "";
- function imageFileAsBase64(element) {
- var file = element.files[0];
- var reader = new FileReader();
- reader.onloadend = function() {
- imagebase64 = reader.result;
- }
- reader.readAsDataURL(file);
- }
Subscribe to:
Posts (Atom)