Please how do I get the current battery level of a phone | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please how do I get the current battery level of a phone

JavaScript navigator.battery

11th Sep 2020, 1:09 AM
K_9ne
K_9ne - avatar
2 Answers
11th Sep 2020, 1:12 AM
Divya Mohan
Divya Mohan - avatar
0
navigator.getBattery().then((battery)=>{ console.log(battery.level*100); })
11th Sep 2020, 1:16 AM
Divya Mohan
Divya Mohan - avatar