commit
This commit is contained in:
		
							parent
							
								
									a8b08119b7
								
							
						
					
					
						commit
						25b3010146
					
				| 
						 | 
				
			
			@ -1,11 +1,22 @@
 | 
			
		|||
const ftoc = function() {
 | 
			
		||||
 | 
			
		||||
const ftoc = function(faren) {
 | 
			
		||||
  // [°F] = [°C] × 9⁄5 + 32
 | 
			
		||||
  var toC = ((faren - 32) * (5/9));
 | 
			
		||||
  toC = Math.round(toC * 10) / 10;
 | 
			
		||||
  return toC;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const ctof = function() {
 | 
			
		||||
 | 
			
		||||
const ctof = function(celsius) {
 | 
			
		||||
  // [°C] = ([°F] − 32) × 5⁄9
 | 
			
		||||
  var toF = ((celsius * 1.8) + 32);
 | 
			
		||||
  toF = Math.round(toF * 10) / 10;
 | 
			
		||||
  return toF;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var testVar = ftoc(32);
 | 
			
		||||
var testVar2 = ctof(0);
 | 
			
		||||
console.log(testVar);
 | 
			
		||||
console.log(testVar2);
 | 
			
		||||
 | 
			
		||||
// Do not edit below this line
 | 
			
		||||
module.exports = {
 | 
			
		||||
  ftoc,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,22 +4,22 @@ describe('ftoc', () => {
 | 
			
		|||
  test('works', () => {
 | 
			
		||||
    expect(ftoc(32)).toEqual(0);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('rounds to 1 decimal', () => {
 | 
			
		||||
  test('rounds to 1 decimal', () => {
 | 
			
		||||
    expect(ftoc(100)).toEqual(37.8);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with negatives', () => {
 | 
			
		||||
  test('works with negatives', () => {
 | 
			
		||||
    expect(ftoc(-100)).toEqual(-73.3);
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
describe('ctof', () => {
 | 
			
		||||
  test.skip('works', () => {
 | 
			
		||||
  test('works', () => {
 | 
			
		||||
    expect(ctof(0)).toEqual(32);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('rounds to 1 decimal', () => {
 | 
			
		||||
  test('rounds to 1 decimal', () => {
 | 
			
		||||
    expect(ctof(73.2)).toEqual(163.8);
 | 
			
		||||
  });
 | 
			
		||||
  test.skip('works with negatives', () => {
 | 
			
		||||
  test('works with negatives', () => {
 | 
			
		||||
    expect(ctof(-10)).toEqual(14);
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue