7 kyu

Find the nth Digit of a Number

4,491 of 12,616Goncalerta

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 Trained22308
Total Skips2981
Total Code Submissions57902
Total Times Completed12616
JavaScript Completions4491
C++ Completions1863
Ruby Completions574
Python Completions3625
CoffeeScript Completions14
Swift Completions1145
C# Completions491
Rust Completions639
C Completions139
Total Stars211
% of votes with a positive feedback rating90% of 1790
Total "Very Satisfied" Votes1461
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