TORONTO KIDS COMPUTER CLUB | Friday 19:00 JavaScript Homework 21.11.05.
20048
post-template-default,single,single-post,postid-20048,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Friday 19:00 JavaScript Homework 21.11.05.

09 Nov Friday 19:00 JavaScript Homework 21.11.05.

Question:
Examine the following function definition. Can you spot any problems with the definition? If so, how can you fix the problems?

function format(ohmage)
{
  var result;
  if ohmage >= 1e6
  {
    ohmage = ohmage / 1e6;
    result = ohmage + " Mohms";
  }
  else
  {
    if (ohmage >= 1e3)
      ohmage = ohmage / 1e3;
      result = ohmage + " Kohms";
    else
      result = ohmage + " ohms";
}
alert(result);
No Comments

Sorry, the comment form is closed at this time.