7 kyu

Find the nth Digit of a Number

3,653 of 12,705Goncalerta

Description:

Complete the function that takes two numbers as input, num and nth and return the nth digit of num (counting from right to left).

Note

  • If num is negative, ignore its sign and treat it as a positive value
  • If nth is not positive, return -1
  • Keep in mind that 42 = 00042. This means that findDigit(42, 5) would return 0

Examples(num, nth --> output)

5673, 4 --> 5
129, 2 --> 2
-2825, 3 --> 8
-456, 4 --> 0
0, 20 --> 0
65, 0 --> -1
24, -8 --> -1
Fundamentals

Stats:

CreatedJul 5, 2016
PublishedJul 6, 2016
Warriors Trained22426
Total Skips2994
Total Code Submissions58185
Total Times Completed12705
JavaScript Completions4521
C++ Completions1877
Ruby Completions574
Python Completions3653
CoffeeScript Completions14
Swift Completions1153
C# Completions496
Rust Completions645
C Completions142
Total Stars211
% of votes with a positive feedback rating90% of 1795
Total "Very Satisfied" Votes1466
Total "Somewhat Satisfied" Votes286
Total "Not Satisfied" Votes43
Ad
Contributors
  • Goncalerta Avatar
  • jhoffner Avatar
  • Javatlacati Avatar
  • GiacomoSorbi Avatar
  • matt c Avatar
  • anter69 Avatar
  • JDeBolt Avatar
  • 10XL Avatar
  • Chrono79 Avatar
  • Voile Avatar
  • Souzooka Avatar
  • user8654865 Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • ejini战神 Avatar
Ad